結果

問題 No.129 お年玉(2)
ユーザー mayoko_
提出日時 2015-01-17 10:46:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 188 ms / 5,000 ms
コード長 779 bytes
コンパイル時間 838 ms
コンパイル使用メモリ 73,304 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 23:03:12
合計ジャッジ時間 6,561 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define INF 1000000000

using namespace std;
typedef long long ll;

const ll MOD = 1000000000;

const int MAXN = 10010;
ll C[2][MAXN];

int main(void) {
    ll N, M;
    cin >> N >> M;
    ll n = N;
    n /= 1000;
    n /= M;
    N -= (n*1000) * M;
    N /= 1000;
    // M C Nを求める
    C[0][0] = 1;
    for (int n = 1; n <= M; n++) {
        int nn = n % 2;
        for (int r = 0; r < MAXN; r++) {
            C[nn][r] = (C[1-nn][r-1] + C[1-nn][r]) % MOD;
        }
    }
    cout << C[M%2][N] << endl;
    return 0;
}
0