結果

問題 No.2409 Strange Werewolves
ユーザー Ping Chung ChangPing Chung Chang
提出日時 2023-08-25 17:18:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 883 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 164,360 KB
実行使用メモリ 8,372 KB
最終ジャッジ日時 2023-08-25 17:18:16
合計ジャッジ時間 3,556 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
8,108 KB
testcase_01 AC 52 ms
8,180 KB
testcase_02 AC 53 ms
8,244 KB
testcase_03 WA -
testcase_04 AC 52 ms
8,096 KB
testcase_05 AC 53 ms
8,084 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 52 ms
8,244 KB
testcase_09 AC 52 ms
8,136 KB
testcase_10 AC 52 ms
8,372 KB
testcase_11 AC 53 ms
8,068 KB
testcase_12 AC 52 ms
8,092 KB
testcase_13 AC 53 ms
8,072 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 52 ms
8,092 KB
testcase_17 AC 52 ms
8,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second

const ll mxn = 3e5+10;
const ll mod = 998244353;
ll fac[mxn],ifac[mxn];

ll pw(ll a,ll b){
	ll re = 1;
	while(b){
		if(b&1)re = re*a%mod;
		b>>=1;
		a = a*a%mod;
	}
	return re;
}
ll inv(ll k){
	return pw(k,mod-2);
}

ll C(ll a,ll b){
	if(a>=mxn||b>=mxn)return -1;
	if(a<b)return 0LL;
	return fac[a]*ifac[b]%mod*ifac[a-b]%mod;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll x,y,z,w;
	cin>>x>>y>>z>>w;
	fac[0] = ifac[0] = 1;
	for(int i = 1;i<mxn;i++){
		fac[i] = fac[i-1]*i%mod;
		ifac[i] = inv(fac[i]);
	}
	if(!w)cout<<C(x,z)*fac[x-z]%mod*C(y,w)%mod*fac[y-w]%mod*C(x+y-z-w-1,x-z)%mod;
	else cout<<C(x,z)*fac[x-z]%mod*C(y,w)%mod*fac[y-w]%mod*C(x+y-z-w-1,y-w)%mod;
}
0