結果

問題 No.129 お年玉(2)
ユーザー peroonperoon
提出日時 2019-04-27 17:40:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 414 ms / 5,000 ms
コード長 1,151 bytes
コンパイル時間 1,841 ms
コンパイル使用メモリ 166,232 KB
実行使用メモリ 433,920 KB
最終ジャッジ日時 2024-05-06 12:39:43
合計ジャッジ時間 22,926 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 397 ms
433,920 KB
testcase_01 AC 381 ms
433,792 KB
testcase_02 AC 382 ms
433,792 KB
testcase_03 AC 381 ms
433,664 KB
testcase_04 AC 381 ms
433,792 KB
testcase_05 AC 378 ms
433,792 KB
testcase_06 AC 379 ms
433,664 KB
testcase_07 AC 382 ms
433,792 KB
testcase_08 AC 379 ms
433,792 KB
testcase_09 AC 379 ms
433,792 KB
testcase_10 AC 383 ms
433,664 KB
testcase_11 AC 383 ms
433,920 KB
testcase_12 AC 384 ms
433,920 KB
testcase_13 AC 381 ms
433,792 KB
testcase_14 AC 378 ms
433,792 KB
testcase_15 AC 382 ms
433,792 KB
testcase_16 AC 380 ms
433,792 KB
testcase_17 AC 382 ms
433,664 KB
testcase_18 AC 380 ms
433,792 KB
testcase_19 AC 377 ms
433,664 KB
testcase_20 AC 380 ms
433,792 KB
testcase_21 AC 378 ms
433,792 KB
testcase_22 AC 380 ms
433,792 KB
testcase_23 AC 377 ms
433,792 KB
testcase_24 AC 380 ms
433,792 KB
testcase_25 AC 381 ms
433,792 KB
testcase_26 AC 376 ms
433,664 KB
testcase_27 AC 380 ms
433,792 KB
testcase_28 AC 382 ms
433,664 KB
testcase_29 AC 379 ms
433,792 KB
testcase_30 AC 382 ms
433,792 KB
testcase_31 AC 380 ms
433,792 KB
testcase_32 AC 382 ms
433,664 KB
testcase_33 AC 383 ms
433,792 KB
testcase_34 AC 382 ms
433,792 KB
testcase_35 AC 383 ms
433,792 KB
testcase_36 AC 380 ms
433,792 KB
testcase_37 AC 414 ms
433,792 KB
testcase_38 AC 381 ms
433,920 KB
testcase_39 AC 382 ms
433,664 KB
testcase_40 AC 381 ms
433,792 KB
testcase_41 AC 380 ms
433,664 KB
testcase_42 AC 381 ms
433,664 KB
testcase_43 AC 381 ms
433,792 KB
testcase_44 AC 380 ms
433,664 KB
testcase_45 AC 381 ms
433,920 KB
testcase_46 AC 382 ms
433,664 KB
testcase_47 AC 383 ms
433,792 KB
testcase_48 AC 384 ms
433,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

// パスカルの三角形セット
const int N_MAX = 10010;
ll pascal[N_MAX][N_MAX] = {};
void calc_pascal(){
    FOR(i, 0, N_MAX){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    FOR(i, 2, N_MAX){
        for(int j=1; j<=i; j++){
            pascal[i][j] = pascal[i-1][j] + pascal[i-1][j-1];
            pascal[i][j] %= 1000000000; // 今回の問題用
        }
    }
}
ll nCr(ll n, ll r){
    return pascal[n][r];
}

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

    // input
    ll N, M;
    cin >> N >> M;

    N /= 1000;
    ll rest = N%M;

    calc_pascal();
    ll ans = nCr(M, rest);
    p(ans);
    
    return 0;
}
0