发奖学金咯^_^
Time Limit:1000MS Memory Limit:65536K
Total Submit:208 Accepted:115
Description
作为安科的同鞋们,最盼望的日子就是每年的11月了,因为这个月是发奖金的日子,养家糊口就靠它了,呵呵。
但是对于学校财务处的工作人员来说,这一天则是很忙碌的一天,财务处最近就在考虑一个问题:如果每个同鞋的奖金额都知道,最少需要准备多少张人民币,才能在给每个同鞋发奖金的时候都不用找零呢?于是他们联系我们可爱的小赵老师,让他帮忙编写一个程序。
这里假设同鞋的奖金都是正整数,单位元,人民币一共有100元、50元、10元、5元、2元和1元六种。
Input
输入数据包含多个测试实例,每个测试实例的第一行是一个整数n(n<100),表示同鞋的人数,然后是n个同鞋的工资。
n=0表示输入的结束,不做处理。
Output
对于每个测试实例输出一个整数x,表示至少需要准备的人民币张数。每个输出占一行。
Sample Input
3
1 2 3
0
Sample Output
4
Source
zxw
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AK1063 {
class Program {
static int f(int n)//该函数由Problem_1041改编而来
{
int[] b = { 100, 50, 10, 5, 2, 1 }; //开数组,储存币种
int kk;
int count = 0;
for (int i = 0; i < 6; i++) {
kk = n / b[i];//除即可得kk张面值为a[i]的零钱
n %= b[i];
count += kk;
}
return count;
}
static void Main(string[] args) {
string sb;
while ((sb = Console.ReadLine()) != null) {
int n = int.Parse(sb);
if (n == 0) break;
string[] s = Console.ReadLine().Split();
int sum = 0;
for (int i = 0; i < n; i++) {
int x = int.Parse(s[i]);
sum += f(x);
}
Console.WriteLine(sum);
}
}
}
}