結果

問題 No.42 貯金箱の溜息
ユーザー 沙耶花沙耶花
提出日時 2021-10-27 17:54:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 807 bytes
コンパイル時間 4,791 ms
コンパイル使用メモリ 257,868 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-16 12:43:52
合計ジャッジ時間 17,662 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,362 ms
5,248 KB
testcase_01 TLE -
testcase_02 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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<vector<int>> a(2);

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[(M^i)&1].size()){
				ndp[(i + a[(M^i)&1][j])>>1] += dp[i];
			}
		}
		swap(dp,ndp);
		M>>=1;
	}
	
	cout<<dp[0].val()<<endl;	
}

int main(){
	
	vector<int> t = {1,5,10,50,100,500};
	int c = 0;
	rep(i,1<<t.size()){
		int s = 0;
		rep(j,t.size()){
			if((i>>j)&1)s += t[j];
		}
		a[s%2].push_back(s);
	}
	//cout<<c<<endl;
	
	mint::set_mod(1000000009);
	
	int _t;
	cin>>_t;
	
	rep(_,_t)solve();
	
	return 0;
}
0