yukicoder - No.32 貯金箱の憂鬱
貪欲法ですね。高い紙幣・硬貨から順に使っていく。
signed main() { int L,M,N; cin>>L>>M>>N; int res = 0; # 1000円以上は全部無視 int amount = (L * 100 + M * 25 + N) % 1000; amount %= 1000; # 100円 res += amount / 100; amount %= 100; # 25円 res += amount / 25; amount %= 25; # 残りの1円 res += amount; cout << res << endl; return 0; }