結果
| 問題 | No.42 貯金箱の溜息 | 
| コンテスト | |
| ユーザー |  紙ぺーぱー | 
| 提出日時 | 2016-05-31 21:40:21 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3,798 ms / 5,000 ms | 
| コード長 | 563 bytes | 
| コンパイル時間 | 1,498 ms | 
| コンパイル使用メモリ | 166,900 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-08 01:21:19 | 
| 合計ジャッジ時間 | 11,195 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 3 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int MOD=1000000009;
const int SZ=1350;
const int a[]{1,5,10,50,100,500};
int dp[SZ]{};
int ndp[SZ]{};
int main(){
  int t;
  cin>>t;
  while(t--){
    long long m;
    cin>>m;
    for(int i=0;i<SZ;i++)dp[i]=ndp[i]=0;
    dp[0]=1;
    while(m){
      for(int i=0;i<SZ;i++){ndp[i]=dp[i];dp[i]=0;}
      for(int i=0;i<6;i++)
        for(int j=SZ-1;j>=a[i];j--)
         if((ndp[j]+=ndp[j-a[i]])>=MOD)ndp[j]-=MOD;
      for(int i=m&1;i<SZ;i+=2)
        dp[i/2]=ndp[i];
      m/=2;
    }
    cout<<dp[0]<<endl;
  }
}
            
            
            
        