結果
問題 | No.1771 A DELETEQ |
ユーザー |
|
提出日時 | 2021-12-03 17:09:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 116 ms / 3,500 ms |
コード長 | 1,432 bytes |
コンパイル時間 | 665 ms |
コンパイル使用メモリ | 73,300 KB |
実行使用メモリ | 6,528 KB |
最終ジャッジ日時 | 2024-07-05 20:42:16 |
合計ジャッジ時間 | 4,797 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 1 RE * 11 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int MOD = 998244353; int main(){ const int maxSize = 100001; vector<long long> inv(maxSize); vector<long long> fact(maxSize); vector<long long> factInv(maxSize); vector<long long> pow2(maxSize); for(int i=0;i<2;i++) inv[i] = fact[i] = factInv[i] = 1; for(int i=2;i<maxSize;i++){ inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; fact[i] = fact[i-1] * i % MOD; factInv[i] = factInv[i-1] * inv[i] % MOD; } pow2[0] = 1; for(int i=1;i<maxSize;i++) pow2[i] = (pow2[i-1] * 2) % MOD; auto comb = [&](int n, int r){ if(n < r || r < 0) return 0LL; return fact[n] * factInv[n-r] % MOD * factInv[r] % MOD; }; auto perm = [&](int n, int r){ if(n < r || r < 0) return 0LL; return fact[n] * factInv[n-r] % MOD; }; int x, y; while(cin >> x >> y){ long long res = 0; if(x > 4000 || y > 4000){ cout << 0 << endl; } for(int i=0;i<=min(x, y);i++){ int a = x-i; int b = y-i; for(int j=0;j<=min(a, b);j++){ int ab = a-j; int ba = b-j; int aa = j; res += comb(ab+ba, ab) * comb(ab+ba+aa, aa) % MOD * pow2[aa] % MOD; res %= MOD; } } cout << res << endl; } }