結果
問題 | No.2409 Strange Werewolves |
ユーザー |
![]() |
提出日時 | 2023-08-11 21:54:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 98 ms / 2,000 ms |
コード長 | 878 bytes |
コンパイル時間 | 4,001 ms |
コンパイル使用メモリ | 253,164 KB |
最終ジャッジ日時 | 2025-02-16 01:19:09 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; template <typename mint> struct combination { vector<mint> fact,factinv; combination(int n) { fact.resize(n+1); factinv.resize(n+1); fact[0]=1; for (int i=1;i<=n;i++) { fact[i]=fact[i-1]*i; } for (int i=0;i<=n;i++) { factinv[i]=fact[i].inv(); } } mint nCr(long long n,long long r) { if (n<0||r<0||n-r<0) { return 0; } return fact[n]*factinv[r]*factinv[n-r]; } mint nPr(long long n,long long r) { if (n<0||r<0||n-r<0) { return 0; } return fact[n]*factinv[n-r]; } }; int main() { ios::sync_with_stdio(0); cin.tie(0); using mint=modint998244353; int x,y,z,w; cin>>x>>y>>z>>w; combination<mint> c(x+y); cout<<(c.nCr(x,z)*c.nCr(y,w)*c.fact[x+y-z-w-1]*(z==0?x:y)).val()<<endl; }