結果
問題 | No.2409 Strange Werewolves |
ユーザー |
|
提出日時 | 2023-08-25 17:18:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 883 bytes |
コンパイル時間 | 1,634 ms |
コンパイル使用メモリ | 166,348 KB |
実行使用メモリ | 8,192 KB |
最終ジャッジ日時 | 2024-12-24 02:43:29 |
合計ジャッジ時間 | 3,355 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 WA * 5 |
ソースコード
#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 secondconst 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;}