結果
| 問題 | No.2409 Strange Werewolves | 
| コンテスト | |
| ユーザー |  keisuke6 | 
| 提出日時 | 2023-08-11 21:28:51 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 899 bytes | 
| コンパイル時間 | 2,038 ms | 
| コンパイル使用メモリ | 194,756 KB | 
| 最終ジャッジ日時 | 2025-02-16 01:02:55 | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 7 WA * 9 | 
コンパイルメッセージ
In file included from /usr/include/c++/13/bits/stl_pair.h:61,
                 from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from main.cpp:1:
In function ‘std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = long long int]’,
    inlined from ‘int main()’ at main.cpp:28:7:
/usr/include/c++/13/bits/move.h:198:11: warning: ‘d’ may be used uninitialized [-Wmaybe-uninitialized]
  198 |       __a = _GLIBCXX_MOVE(__b);
      |           ^
main.cpp: In function ‘int main()’:
main.cpp:25:19: note: ‘d’ was declared here
   25 |         int a,b,c,d;
      |                   ^
            
            ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 998244353;
vector<long long> fact, fact_inv, inv;
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}
long long nCk(int n, int k) {
    if(n < k || n < 0 || k < 0) return 0;
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}
signed main(){
	init_nCk(700000);
	int a,b,c,d;
	cin>>a>>b>>c,d;
	if(c == 0){
		swap(c,d);
		swap(a,b);
	}
	int ans = nCk(a+b-c-1,b-1);
	for(int i=1;i<=b;i++) ans = (ans*i)%mod;
	for(int i=a;i>c;i--) ans = (ans*i)%mod;
	cout<<ans<<endl;
}
            
            
            
        