hdu2021(发工资咯:)

来源:互联网 发布:pygtk python 编辑:程序博客网 时间:2024/04/28 18:22
#include <iostream>#include <cstdio>using namespace std;const int maxn = 110;int person[maxn];int n;int num = 0;int work(int x) {    int tmp = 0;    while(x >= 100) {        x -= 100;        tmp ++;    }    while(x >= 50) {        x -= 50;        tmp ++;    }    while(x >= 10) {        x -= 10;        tmp ++;    }    while(x >= 5) {        x -= 5;        tmp ++;    }    while(x >= 2) {        x -= 2;        tmp ++;    }    while(x >= 1) {       x -= 1;       tmp++;    }    return tmp;}int main(){    while(scanf("%d", &n) != EOF) {        if(0 == n) { break; }        for(int i = 1; i <= n; i++) {            scanf("%d", &person[i]);            int tmp =  work(person[i]);            num += tmp;        }        cout << num << endl;        num = 0;    }    return 0;}

原创粉丝点击