結果

問題 No.129 お年玉(2)
ユーザー otsnskotsnsk
提出日時 2015-01-18 22:10:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 71 ms / 5,000 ms
コード長 873 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 54,900 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 22:21:04
合計ジャッジ時間 3,096 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,248 KB
testcase_01 AC 71 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 30 ms
5,376 KB
testcase_06 AC 46 ms
5,376 KB
testcase_07 AC 56 ms
5,376 KB
testcase_08 AC 39 ms
5,376 KB
testcase_09 AC 51 ms
5,376 KB
testcase_10 AC 61 ms
5,376 KB
testcase_11 AC 37 ms
5,376 KB
testcase_12 AC 50 ms
5,376 KB
testcase_13 AC 52 ms
5,376 KB
testcase_14 AC 49 ms
5,376 KB
testcase_15 AC 39 ms
5,376 KB
testcase_16 AC 45 ms
5,376 KB
testcase_17 AC 56 ms
5,376 KB
testcase_18 AC 54 ms
5,376 KB
testcase_19 AC 57 ms
5,376 KB
testcase_20 AC 55 ms
5,376 KB
testcase_21 AC 70 ms
5,376 KB
testcase_22 AC 39 ms
5,376 KB
testcase_23 AC 61 ms
5,376 KB
testcase_24 AC 56 ms
5,376 KB
testcase_25 AC 37 ms
5,376 KB
testcase_26 AC 38 ms
5,376 KB
testcase_27 AC 40 ms
5,376 KB
testcase_28 AC 70 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 9 ms
5,376 KB
testcase_39 AC 13 ms
5,376 KB
testcase_40 AC 37 ms
5,376 KB
testcase_41 AC 22 ms
5,376 KB
testcase_42 AC 10 ms
5,376 KB
testcase_43 AC 10 ms
5,376 KB
testcase_44 AC 71 ms
5,376 KB
testcase_45 AC 6 ms
5,376 KB
testcase_46 AC 14 ms
5,376 KB
testcase_47 AC 67 ms
5,376 KB
testcase_48 AC 40 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

#define FORR(i,b,e) for(int i=(b);i<(int)(e);++i)
#define FOR(i,e) FORR(i,0,e)
#define dump(var) cerr << #var ": " << var << "\n"
#define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n"

typedef long long ll;
typedef unsigned long long ull;

const ull MODD = 1e9;

using namespace std;

ull pt[2][10100];
ull count_combinations_pascal(ull n, ull k) {
    fill(pt[0], pt[0]+10100, 0);
    fill(pt[1], pt[1]+10100, 0);

    pt[0][0] = pt[1][0] = 1;

    for (int i = 1; i <= n; ++i) {
        ull *ra = pt[(i-1)&1], *rb = pt[i&1];
        for (int j = 1; j <= i + 1; ++j) {
            rb[j] = (ra[j-1] + ra[j]) % MODD;
        }
    }
    return pt[n&1][k];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ull N, M;
    cin >> N >> M;
    N /= 1000;
    cout << count_combinations_pascal(M, N%M) << endl;

    return 0;
}
0