原题链接
因为数据太水,我直接一发暴力过了......
#include <cstdio> using namespace std;int value[5] = {100, 20, 10, 5, 1};int main() {int n, ans = 0;scanf("%d", &n);while(n > 0) {for(int i = 0; i < 5; i ++) {if(n >= value[i]) {ans ++;n -= value[i];break;}}}printf("%d\n", ans);return 0; }
#include <cstdio> using namespace std;int value[5] = {100, 20, 10, 5, 1};int main() {int n, ans = 0;scanf("%d", &n);for(int i = 0; i < 5; i ++) {if(n >0) {ans += (n / value[i]);n = n % value[i];}}printf("%d\n", ans);return 0; }