結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー ano184ano184
提出日時 2014-10-18 03:04:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 178 ms / 5,000 ms
コード長 687 bytes
コンパイル時間 593 ms
コンパイル使用メモリ 75,516 KB
実行使用メモリ 9,260 KB
最終ジャッジ日時 2023-08-28 21:18:12
合計ジャッジ時間 1,566 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 174 ms
9,260 KB
testcase_01 AC 178 ms
8,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0