結果
| 問題 | No.2409 Strange Werewolves |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-23 02:22:15 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 16 ms / 2,000 ms |
| + 80µs | |
| コード長 | 783 bytes |
| 記録 | |
| コンパイル時間 | 1,092 ms |
| コンパイル使用メモリ | 179,932 KB |
| 実行使用メモリ | 22,172 KB |
| 最終ジャッジ日時 | 2026-09-23 02:22:19 |
| 合計ジャッジ時間 | 2,806 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
ll modpow(ll a, ll b, ll p){
a%=p;
ll ans=1;
while(b>0){
if(b%2==1) ans=(ans*a)%p;
b/=2;
a=(a*a)%p;
}
return ans;
}
pair<vector<ll>, vector<ll>> factorial(int n, ll mod){
vector<ll> fact(n+1, 1), invfact(n+1, 1);
for(ll i=2; i<=n; i++) fact[i]=fact[i-1]*i%mod;
invfact[n]=modpow(fact[n], mod-2, mod);
for(ll i=n-1; i>=1; i--) invfact[i]=invfact[i+1]*(i+1)%mod;
return {fact, invfact};
}
int main(void){
ll x, y, z, w; cin >> x >> y >> z >> w;
if(w==0) swap(x, y), swap(z, w);
ll ans=1, mod=998244353;
auto [fact, inv]=factorial(6e5+1, mod);
ans=fact[y]*inv[w]%mod*inv[y-w]%mod*fact[x+y-w-1]%mod*x%mod;
cout << ans << endl;
return 0;
}