<span style= "Color:blue; font-family: ' Helvetica Neue ', Helvetica, Arial, Sans-serif; font-size:24px; line-height:36px; Background-color:rgb (255, 255, 255); " >Description</span>
As SDIBT's teacher, the most expected day is the monthly number 10th, because this is the day of wages, the breadwinner depends on it, hehe but for the school Finance Department staff, this day is a very busy day, Xiao Hu, the Finance department, has recently been thinking about a question: if every teacher's salary is known, at least how many yuan to prepare, in order to pay for each teacher without teacher change? This assumes that the teacher's wages are positive integers, unit yuan, a total of 100 yuan, 50 yuan, 10 yuan, 5 yuan, 2 yuan and 1 Yuan six.
Input
The input data contains multiple test instances, and the first line of each test instance is an integer n (n<100), which indicates the number of teachers and then the wages of N teachers. N=0 indicates the end of the input and does not handle it.
Output
Output an integer x for each test instance to indicate the minimum number of renminbi to be prepared. Each output occupies one row.
Sample Input
31 2 30
Sample Output
4
HINT
The code is as follows:
#include <iostream>using namespace Std;int main () { int n,i,num=0; int a[100]; while (cin>>n&&n!=0) {for (i=0; i<n; i++) cin>>a[i]; for (i=0; i<n; i++) { num+=a[i]/100; if (a[i]%100==0) continue; else a[i]%=100; NUM+=A[I]/50; if (a[i]%50==0) continue; else a[i]%=50; NUM+=A[I]/10; if (a[i]%10==0) continue; else a[i]%=10; NUM+=A[I]/5; if (a[i]%5==0) continue; else a[i]%=5; NUM+=A[I]/2; if (a[i]%2==0) continue; else a[i]%=2; Num+=a[i]; } cout<<num<<endl; num=0; } return 0;}
Operation Result:
Greedy algorithm is very useful.
OJ Brush the problem of "pay"