結果

問題 No.129 お年玉(2)
ユーザー RonlynesRonlynes
提出日時 2017-09-11 22:49:40
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 98 ms / 5,000 ms
コード長 549 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 54,616 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-28 01:00:44
合計ジャッジ時間 4,117 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

const int mod = 1e9;
int main(void){
    long long n,m;
    cin >> n >> m;
    long long k = (n/1000)%m;
    long long before[10003], after[10003];
    before[0] = 1;
    if(k != 0){
        for(int i=1; i<=m; i++){
            for(int j=1; j<=i; j++){
                after[j] = (before[j-1]+before[j])%mod;
            }
            before[0] = 1;
            for(int j=1; j<=i; j++){
                before[j] = after[j];
            }
        }
    }
    cout << (before[k]%mod) << endl;
    return 0;
}
0