結果
| 問題 | No.2409 Strange Werewolves | 
| コンテスト | |
| ユーザー |  pengin_2000 | 
| 提出日時 | 2023-08-11 21:39:28 | 
| 言語 | C (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 9 ms / 2,000 ms | 
| コード長 | 859 bytes | 
| コンパイル時間 | 202 ms | 
| コンパイル使用メモリ | 30,464 KB | 
| 実行使用メモリ | 9,600 KB | 
| 最終ジャッジ日時 | 2024-11-18 15:38:27 | 
| 合計ジャッジ時間 | 1,007 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 16 | 
ソースコード
#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;
}
            
            
            
        