結果
問題 | No.42 貯金箱の溜息 |
ユーザー | t98slider |
提出日時 | 2022-11-09 00:12:46 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 14 ms / 5,000 ms |
コード長 | 941 bytes |
コンパイル時間 | 2,950 ms |
コンパイル使用メモリ | 139,368 KB |
実行使用メモリ | 4,376 KB |
最終ジャッジ日時 | 2023-09-29 13:35:44 |
合計ジャッジ時間 | 3,390 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
4,376 KB |
testcase_01 | AC | 14 ms
4,376 KB |
testcase_02 | AC | 14 ms
4,376 KB |
ソースコード
#include <atcoder/all> using namespace std; using ll = long long; using modint = atcoder::static_modint<1000000009>; int main(){ ios::sync_with_stdio(false); cin.tie(0); 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'; } }