結果
| 問題 |
No.42 貯金箱の溜息
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-09 00:05:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 955 bytes |
| コンパイル時間 | 1,059 ms |
| コンパイル使用メモリ | 91,492 KB |
| 最終ジャッジ日時 | 2024-07-22 07:47:51 |
| 合計ジャッジ時間 | 1,629 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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:23:13: error: 'cout' was not declared in this scope
23 | cout << dp[M].val() << '\n';
| ^~~~
main.cpp:23:13: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
main.cpp:37:9: error: 'cout' was not declared in this scope
37 | cout << ans.val() << '\n';
| ^~~~
main.cpp:37: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::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';
}
}