結果
| 問題 |
No.42 貯金箱の溜息
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-10-27 17:49:49 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 798 bytes |
| コンパイル時間 | 4,744 ms |
| コンパイル使用メモリ | 251,680 KB |
| 最終ジャッジ日時 | 2025-01-25 07:46:23 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 3 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000
vector<int> a;
void solve(){
long long M;
cin>>M;
vector<mint> dp(666,0);
dp[0] = 1;
while(M!=0){
vector<mint> ndp(666,0);
rep(i,666){
if(dp[i]==0)continue;
rep(j,a.size()){
int ni = i+a[j];
if((ni&1)!=(M&1))continue;
ni >>= 1;
ndp[ni] += dp[i];
}
}
swap(dp,ndp);
M>>=1;
}
cout<<dp[0].val()<<endl;
}
int main(){
vector<int> t = {1,5,10,50,100,500};
rep(i,1<<t.size()){
int s = 0;
rep(j,t.size()){
if((i>>j)&1)s += t[j];
}
a.push_back(s);
}
mint::set_mod(1000000009);
int _t;
cin>>_t;
rep(_,_t)solve();
return 0;
}
沙耶花