結果
問題 | No.42 貯金箱の溜息 |
ユーザー |
|
提出日時 | 2022-11-09 00:05:51 |
言語 | C++14 (gcc 11.2.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 25 ms / 5,000 ms |
コード長 | 955 bytes |
コンパイル時間 | 2,549 ms |
使用メモリ | 6,252 KB |
最終ジャッジ日時 | 2023-02-22 01:00:00 |
合計ジャッジ時間 | 3,473 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 18 ms
6,252 KB |
testcase_01 | AC | 24 ms
6,192 KB |
testcase_02 | AC | 25 ms
6,192 KB |
ソースコード
#include <atcoder/all> using namespace std; using ll = long long; using modint = atcoder::modint; int main(){ ios::sync_with_stdio(false); cin.tie(0); modint::set_mod(1000000009); vector<modint> dp(3000, 1); vector<int> coin = {1, 5, 10, 50, 100, 500}; for(int i = 1; i < coin.size(); i++){ for(int j = coin[i]; j < 3000; j++){ dp[j] += dp[j - coin[i]]; } } int T; cin >> T; while(T--){ long long M, m; cin >> M; if(M < 3000){ cout << dp[M].val() << '\n'; continue; } m = M % 500; modint ans; for(int i = m; i < 3000; i += 500){ modint c = 1, d = 1; for(int j = m; j < 3000; j += 500){ if(j == i)continue; c *= (M - j); d *= (i - j); } ans += dp[i] * c / d; } cout << ans.val() << '\n'; } }