結果

問題 No.2409 Strange Werewolves
ユーザー zezerozezero
提出日時 2023-08-11 22:41:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,489 bytes
コンパイル時間 2,918 ms
コンパイル使用メモリ 179,664 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-29 13:48:18
合計ジャッジ時間 3,615 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,504 KB
testcase_01 AC 6 ms
5,760 KB
testcase_02 AC 5 ms
5,504 KB
testcase_03 WA -
testcase_04 AC 6 ms
5,632 KB
testcase_05 AC 5 ms
5,504 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 5 ms
5,504 KB
testcase_09 AC 5 ms
5,504 KB
testcase_10 AC 5 ms
5,504 KB
testcase_11 AC 6 ms
5,504 KB
testcase_12 AC 5 ms
5,760 KB
testcase_13 AC 5 ms
5,632 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 6 ms
5,504 KB
testcase_17 AC 6 ms
5,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(300000);// 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;
}
0