結果
問題 | No.41 貯金箱の溜息(EASY) |
ユーザー |
![]() |
提出日時 | 2014-10-18 03:04:01 |
言語 | C++11 (gcc 8.5.0) |
結果 |
AC
|
実行時間 | 163 ms / 5,000 ms |
コード長 | 687 bytes |
コンパイル時間 | 524 ms |
使用メモリ | 9,148 KB |
最終ジャッジ日時 | 2023-01-16 08:09:04 |
合計ジャッジ時間 | 1,666 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 159 ms
9,148 KB |
testcase_01 | AC | 163 ms
9,060 KB |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <numeric> #include <map> #define repf(x,from,to) for(int (x)=(from);(x)<(to);(x)++) typedef long long ll; using namespace std; int main() { const ll MOD=1000000009, MMX=10000000000; map<ll,ll> mp; vector<int> su; repf(i,1,10) su.push_back(111111*i); mp[0]=1LL;mp[MMX*2]=0LL; repf(i,0,9) for(auto& x: mp){ if(su[i]+x.first <= MMX) (mp[su[i]+x.first] += x.second) %=MOD; } ll w=0; for(auto& x: mp){ (x.second += w)%=MOD; w=x.second; } int T; cin >> T; while( T--){ ll M; cin >> M; auto it = mp.upper_bound(M); it--; cout << it->second <<endl; } return 0; }