結果

問題 No.2409 Strange Werewolves
ユーザー pengin_2000pengin_2000
提出日時 2023-08-11 21:39:28
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-04-29 12:30:12
合計ジャッジ時間 1,018 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
9,472 KB
testcase_01 AC 11 ms
9,600 KB
testcase_02 AC 11 ms
9,600 KB
testcase_03 AC 12 ms
9,600 KB
testcase_04 AC 12 ms
9,600 KB
testcase_05 AC 11 ms
9,600 KB
testcase_06 AC 11 ms
9,472 KB
testcase_07 AC 11 ms
9,472 KB
testcase_08 AC 11 ms
9,600 KB
testcase_09 AC 11 ms
9,600 KB
testcase_10 AC 11 ms
9,600 KB
testcase_11 AC 11 ms
9,600 KB
testcase_12 AC 11 ms
9,600 KB
testcase_13 AC 11 ms
9,600 KB
testcase_14 AC 11 ms
9,600 KB
testcase_15 AC 12 ms
9,600 KB
testcase_16 AC 11 ms
9,600 KB
testcase_17 AC 11 ms
9,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
long long int fact[1000006];
long long int modpow(long long int a, long long int n, long long int p)
{
	long long int res = 1;
	for (; n > 0; n /= 2, a = a * a % p)
		if (n % 2 > 0)
			res = res * a % p;
	return res;
}
long long int comb(long long int n, long long int r, long long int p)
{
	long long int res = fact[n];
	res = res * modpow(fact[r], p - 2, p) % p;
	res = res * modpow(fact[n - r], p - 2, p) % p;
	return res;
}
int main()
{
	long long int x, y, z, w;
	scanf("%lld %lld %lld %lld", &x, &y, &z, &w);
	const long long int p = 998244353;
	long long int i;
	fact[0] = 1;
	for (i = 1; i < 1000006; i++)
		fact[i] = fact[i - 1] * i % p;
	long long int ans = comb(x, z, p) * comb(y, w, p) % p;
	if (z > 0)
		ans = ans * y % p;
	else
		ans = ans * x % p;
	ans = ans * fact[x + y - z - w - 1] % p;
	printf("%lld\n", ans);
	return 0;
}
0