結果

問題 No.129 お年玉(2)
ユーザー tsukiotsukio
提出日時 2016-03-04 20:25:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 210 ms / 5,000 ms
コード長 528 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 51,804 KB
実行使用メモリ 198,988 KB
最終ジャッジ日時 2023-08-18 17:35:49
合計ジャッジ時間 6,448 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
13,024 KB
testcase_01 AC 206 ms
198,988 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 85 ms
83,020 KB
testcase_06 AC 133 ms
130,240 KB
testcase_07 AC 159 ms
159,112 KB
testcase_08 AC 110 ms
109,152 KB
testcase_09 AC 147 ms
146,700 KB
testcase_10 AC 163 ms
165,004 KB
testcase_11 AC 102 ms
104,644 KB
testcase_12 AC 133 ms
136,184 KB
testcase_13 AC 139 ms
142,392 KB
testcase_14 AC 137 ms
137,696 KB
testcase_15 AC 117 ms
113,488 KB
testcase_16 AC 127 ms
128,836 KB
testcase_17 AC 155 ms
156,356 KB
testcase_18 AC 151 ms
147,116 KB
testcase_19 AC 154 ms
157,204 KB
testcase_20 AC 152 ms
155,696 KB
testcase_21 AC 194 ms
194,308 KB
testcase_22 AC 108 ms
110,432 KB
testcase_23 AC 169 ms
170,052 KB
testcase_24 AC 164 ms
163,200 KB
testcase_25 AC 107 ms
105,400 KB
testcase_26 AC 109 ms
107,824 KB
testcase_27 AC 112 ms
104,760 KB
testcase_28 AC 201 ms
196,212 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 3 ms
4,596 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 3 ms
4,600 KB
testcase_37 AC 3 ms
5,044 KB
testcase_38 AC 24 ms
24,292 KB
testcase_39 AC 37 ms
35,736 KB
testcase_40 AC 101 ms
97,928 KB
testcase_41 AC 61 ms
60,412 KB
testcase_42 AC 25 ms
27,216 KB
testcase_43 AC 25 ms
26,800 KB
testcase_44 AC 203 ms
197,372 KB
testcase_45 AC 15 ms
16,172 KB
testcase_46 AC 42 ms
39,796 KB
testcase_47 AC 210 ms
190,684 KB
testcase_48 AC 116 ms
115,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

const long long kMod = 1000000000;

long long CalcCombination(int n, int r) {
	int** dp = new int*[n + 1];
	for (int i = 0; i < n + 1; i++) {
		dp[i] = new int[i + 1];
		for (int j = 0; j < i + 1; j++) {
			if (j == 0 || j == i) {
				dp[i][j] = 1;
			}
			else {
				dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % kMod;
			}
		}
	}

	return dp[n][r];
}

int main() {
	long long n;
	int m;
	cin >> n >> m;

	int r = (n / 1000) % m;
	cout << CalcCombination(m, r) << endl;

	return 0;
}
0