結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー ayame_pyayame_py
提出日時 2016-01-20 15:30:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 698 bytes
コンパイル時間 1,379 ms
コンパイル使用メモリ 160,008 KB
実行使用メモリ 5,208 KB
最終ジャッジ日時 2023-10-21 13:32:07
合計ジャッジ時間 1,942 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
5,208 KB
testcase_01 AC 22 ms
5,208 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:27: warning: iteration 99999 invokes undefined behavior [-Waggressive-loop-optimizations]
   20 |             just_dp[i + j]+=just_dp[j];
      |             ~~~~~~~~~~~~~~^~~~~~~~~~~~
main.cpp:4:35: note: within this loop
    4 | #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                                   ^
main.cpp:19:9: note: in expansion of macro ‘REP’
   19 |         REP(j,MAX_Md){
      |         ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i < (ll)(m); i++)
#define INF 1000000009
#define pb push_back
#define MAX_Md 100000

typedef long long ll;

int T;
ll just_dp[MAX_Md]; //丁度n枚を表す
ll dp[MAX_Md+1]={0};

int main(){
    just_dp[0]=1;
    FOR(i,1,10){
        REP(j,MAX_Md){
            just_dp[i + j]+=just_dp[j];
            just_dp[i + j]%=INF;
        }
    }
    
    dp[0]=0;
    REP(i,MAX_Md){
        dp[i+1]=dp[i]+just_dp[i];
        dp[i+1]%=INF;
    }
    
    cin >> T;
    REP(i,T){
        ll M;
        cin >> M;
        cout << dp[M/111111+1] << endl;
    }
    
    return 0;
}
0