結果

問題 No.42 貯金箱の溜息
ユーザー 沙耶花
提出日時 2021-10-27 17:54:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 807 bytes
コンパイル時間 4,684 ms
コンパイル使用メモリ 253,244 KB
最終ジャッジ日時 2025-01-25 07:47:03
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

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