結果

問題 No.1989 Pairing Multiset
ユーザー 👑 ygussanyygussany
提出日時 2022-06-24 21:52:58
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 1,200 ms
コンパイル使用メモリ 28,656 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-08 12:08:57
合計ジャッジ時間 1,751 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
4,376 KB
testcase_01 AC 20 ms
4,380 KB
testcase_02 AC 20 ms
4,376 KB
testcase_03 AC 20 ms
4,376 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 20 ms
4,376 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 AC 19 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 7 ms
4,376 KB
testcase_11 AC 13 ms
4,376 KB
testcase_12 AC 14 ms
4,376 KB
testcase_13 AC 19 ms
4,380 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 17 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 20 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

const int Mod = 998244353;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int main()
{
	int N, M;
	scanf("%d %d", &N, &M);
	
	int i;
	long long ans = (long long)M * N % Mod, tmp;
	for (i = M + N * 2; i > M; i--) ans = ans * i % Mod;
	for (i = 2, tmp = 1; i <= N * 2; i++) tmp = tmp * i % Mod;
	ans = div_mod(ans, tmp, Mod);
	printf("%lld\n", div_mod(ans, N * 2 + 1, Mod));
	fflush(stdout);
	return 0;
}
0