結果
| 問題 | No.2409 Strange Werewolves | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-08-11 22:42:41 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 11 ms / 2,000 ms | 
| コード長 | 1,489 bytes | 
| コンパイル時間 | 3,031 ms | 
| コンパイル使用メモリ | 172,548 KB | 
| 最終ジャッジ日時 | 2025-02-16 01:51:30 | 
| ジャッジサーバーID (参考情報) | judge5 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 16 | 
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cmath>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
using mint = modint998244353;
class combination {
public:
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) const {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
	mint p(ll n,ll k) const{
		if (k < 0 || k > n ) return 0;
		return fact[n]*ifact[n-k];
	}
	mint h(ll n,ll k) const {
		if (k < 0 || k > n) return 0;
		return fact[n+k-1]*ifact[n-1]*ifact[k];
	}
	mint choose(ll n ,ll a) const{// k <= 1e5 n <= 1e9
	    if (a < 0 || a > n) return 0;
		mint x=1,y=1;
		for(ll i=0;i < a; i++){
			x*=n-i;
			y*=i+1;
		}
		return x / y; 
	}
	mint perm(ll n, ll a) const { // k <= 1e5
	if (a < 0 || a > n) return 0;
	   mint x=1,y=1;
	   for (ll i=0;i < a;i++){
		   x*=n-i;
	   }
	   return x;
	}
}comb(600000);// plsese mint control!
int main(){
  int x,y,z,w;
  cin >> x >> y >> z >> w;
  if (w == 0){
    swap(x,y);
    swap(z,w);
  }
  cout << (comb(x,1)* comb.fact[x+y-w-1] * comb(y,w)).val() << endl; 
  return 0;
}
            
            
            
        