发奖学金咯^_^ Time Limit:1000MS Memory Limit:65536K Description 作为安科的同鞋们,最盼望的日子就是每年的11月了,因为这个月是发奖金的日子,养家糊口就靠它了,呵呵。 Input 输入数据包含多个测试实例,每个测试实例的第一行是一个整数n(n<100),表示同鞋的人数,然后是n个同鞋的工资。 Output 对于每个测试实例输出一个整数x,表示至少需要准备的人民币张数。每个输出占一行。 Sample Input
3 1 2 3 0 Sample Output
4 Source zxw |
[Submit] [Go Back] [Status] [Discuss]
#include<iostream>
using namespace std;
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;
}
int main()
{
int n,a;
while(cin>>n)
{
int sum=0; //Oh fuck 没有置0
if(n==0)break;
while(n--)
{
cin>>a;
sum+=f(a);
}
cout<<sum<<endl;
}
return 0;
}