結果

問題 No.129 お年玉(2)
ユーザー RubikunRubikun
提出日時 2019-07-31 02:45:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 752 bytes
コンパイル時間 1,882 ms
コンパイル使用メモリ 165,192 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 15:53:25
合計ジャッジ時間 5,247 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,376 KB
testcase_01 AC 138 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 49 ms
4,380 KB
testcase_06 AC 39 ms
4,376 KB
testcase_07 AC 71 ms
4,380 KB
testcase_08 AC 69 ms
4,380 KB
testcase_09 AC 35 ms
4,380 KB
testcase_10 AC 81 ms
4,380 KB
testcase_11 AC 41 ms
4,376 KB
testcase_12 AC 7 ms
4,380 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 41 ms
4,376 KB
testcase_15 AC 34 ms
4,380 KB
testcase_16 AC 48 ms
4,376 KB
testcase_17 AC 31 ms
4,380 KB
testcase_18 AC 71 ms
4,376 KB
testcase_19 AC 95 ms
4,380 KB
testcase_20 AC 60 ms
4,376 KB
testcase_21 AC 38 ms
4,376 KB
testcase_22 AC 49 ms
4,376 KB
testcase_23 AC 80 ms
4,380 KB
testcase_24 AC 107 ms
4,380 KB
testcase_25 AC 40 ms
4,376 KB
testcase_26 AC 57 ms
4,380 KB
testcase_27 AC 53 ms
4,380 KB
testcase_28 AC 62 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,384 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 8 ms
4,376 KB
testcase_39 AC 8 ms
4,380 KB
testcase_40 AC 20 ms
4,376 KB
testcase_41 AC 25 ms
4,380 KB
testcase_42 AC 12 ms
4,376 KB
testcase_43 AC 4 ms
4,380 KB
testcase_44 AC 119 ms
4,376 KB
testcase_45 AC 8 ms
4,380 KB
testcase_46 AC 4 ms
4,376 KB
testcase_47 AC 101 ms
4,384 KB
testcase_48 AC 71 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) (x).begin(),(x).end()
const int mod=1000000000,MAX=100001,INF=1<<30;

int main(){

    ll N,M;cin>>N>>M;
    N/=1000;
    N=N%M;
    int dp[2][N+1];
    for(int i=0;i<2;i++){
        for(int j=0;j<N+1;j++){
            dp[i][j]=0;
        }
    }
    
    dp[0][0]=1;
    
    for(int i=1;i<=M;i++){
        for(int j=0;j<=N;j++){
            if(j==0) dp[i%2][j]=1;
            else dp[i%2][j]=(dp[(i-1)%2][j-1]+dp[(i-1)%2][j])%mod;
        }
    }
    
    /*for(int i=0;i<=M;i++){
        for(int j=0;j<=N;j++){
            if(j) cout<<" ";
            cout<<dp[i][j];
        }
        cout<<endl;
    }*/
    
    cout<<dp[M%2][N]<<endl;
}

0