結果

問題 No.2141 Enumeratest
ユーザー startcppstartcpp
提出日時 2022-12-02 21:35:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 67,932 KB
実行使用メモリ 27,004 KB
最終ジャッジ日時 2024-04-18 05:20:41
合計ジャッジ時間 3,688 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,756 KB
testcase_01 AC 3 ms
7,632 KB
testcase_02 AC 20 ms
14,212 KB
testcase_03 AC 96 ms
26,992 KB
testcase_04 AC 104 ms
27,004 KB
testcase_05 AC 104 ms
26,940 KB
testcase_06 AC 3 ms
7,632 KB
testcase_07 AC 9 ms
8,396 KB
testcase_08 AC 27 ms
18,016 KB
testcase_09 AC 18 ms
14,184 KB
testcase_10 AC 46 ms
22,224 KB
testcase_11 AC 76 ms
26,544 KB
testcase_12 AC 5 ms
9,848 KB
testcase_13 AC 17 ms
13,420 KB
testcase_14 AC 77 ms
26,204 KB
testcase_15 AC 41 ms
20,284 KB
testcase_16 AC 55 ms
22,864 KB
testcase_17 AC 63 ms
21,316 KB
testcase_18 AC 85 ms
25,552 KB
testcase_19 AC 87 ms
25,844 KB
testcase_20 AC 70 ms
23,464 KB
testcase_21 AC 80 ms
25,276 KB
testcase_22 AC 54 ms
22,536 KB
testcase_23 AC 25 ms
14,940 KB
testcase_24 AC 81 ms
26,584 KB
testcase_25 AC 27 ms
17,840 KB
testcase_26 AC 94 ms
26,312 KB
testcase_27 AC 78 ms
25,292 KB
testcase_28 AC 105 ms
26,692 KB
testcase_29 AC 51 ms
20,152 KB
testcase_30 AC 92 ms
26,140 KB
testcase_31 AC 59 ms
23,492 KB
testcase_32 AC 65 ms
22,940 KB
testcase_33 AC 58 ms
23,604 KB
testcase_34 AC 71 ms
25,884 KB
testcase_35 AC 7 ms
8,012 KB
testcase_36 AC 93 ms
26,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int mod = 998244353;
int N, M;
int fact[1000001], inv[1000001], finv[1000001];

void init(int n) {
	fact[0] = fact[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i <= n; i++) {
		fact[i] = i * fact[i - 1] % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

signed main() {
	cin >> N >> M;
	init(max(N, M));

	int ans = fact[M];
	for (int i = 0; i < N; i++) {
		int x = (M / N) + (i < M % N);
		//cout << "x = " << x << endl;
		ans *= finv[x];
		ans %= mod;
	}

	cout << ans << endl;
	return 0;
}
0