题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2021
暴力出解,可能数多了就不行了
题解:
#include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> using namespace std; int a[6]={100,50,10,5,2,1}; int num(int x) { int sum=0; for(int i = 0;i< 6;i++) { int t = x/a[i]; sum+=t; x = x- t*a[i]; } return sum; } int main() { int n,a; while(cin>>n) { if(n==0) break; int count = 0; for(int i = 0;i< n;i++) { cin>>a; count+=num(a); } cout<<count<<endl; } return 0; }