AC代码:
#include<iostream>
#include<iomanip>
#include<math.h>
#include<cstring>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<bits/stdc++.h>
int count(int money)//对每一位员工计数 人民币一共有100元、50元、20元、10元、5元、2元和1元七种
{
int cnt = 0;
if (money >= 100)
{
cnt = cnt + money / 100;
money %= 100;
}
if (money >= 50)
{
cnt = cnt + money / 50;
money %= 50;
}
if (money >= 20)
{
cnt = cnt + money / 20;
money %= 20;
}
if (money >= 10)
{
cnt = cnt + money / 10;
money %= 10;
}
if (money >= 5)
{
cnt = cnt + money / 5;
money %= 5;
}
if (money >= 2)
{
cnt = cnt + money / 2;
money %= 2;
}
if (money >= 1)
{
cnt = cnt + money / 1;
money %= 1;
}
return(cnt);
};
using namespace std;
int main()
{
//测试函数是否正确:cout << count(197);
int t=0;
cin >> t;
int n = 0;
while (cin >> n, t--)
{
int ans = 0;
int a[110];
for (int i = 1; i <= n; i++)
{
cin >> a[i];
ans += count(a[i]);
}
cout << ans << endl;
}
//system("pause");
return 0;
}