結果
問題 | No.42 貯金箱の溜息 |
ユーザー |
|
提出日時 | 2022-11-09 00:12:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 941 bytes |
コンパイル時間 | 699 ms |
コンパイル使用メモリ | 92,476 KB |
最終ジャッジ日時 | 2024-07-22 07:54:17 |
合計ジャッジ時間 | 1,048 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:7:10: error: incomplete type 'std::ios' {aka 'std::basic_ios<char>'} used in nested name specifier 7 | ios::sync_with_stdio(false); | ^~~~~~~~~~~~~~~ main.cpp:8:5: error: 'cin' was not declared in this scope 8 | cin.tie(0); | ^~~ main.cpp:2:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'? 1 | #include <atcoder/all> +++ |+#include <iostream> 2 | using namespace std; main.cpp:22:13: error: 'cout' was not declared in this scope 22 | cout << dp[M].val() << '\n'; | ^~~~ main.cpp:22:13: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'? main.cpp:36:9: error: 'cout' was not declared in this scope 36 | cout << ans.val() << '\n'; | ^~~~ main.cpp:36:9: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
ソースコード
#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';}}