結果
| 問題 |
No.1431 東大文系数学2020第2問改
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-30 16:42:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 767 ms / 5,000 ms |
| コード長 | 1,955 bytes |
| コンパイル時間 | 1,695 ms |
| コンパイル使用メモリ | 169,104 KB |
| 実行使用メモリ | 73,600 KB |
| 最終ジャッジ日時 | 2024-09-15 12:11:00 |
| 合計ジャッジ時間 | 14,378 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
namespace SimpleModInt {
constexpr int md = (int)998244353;
inline int norm(long long a) {
return (a % md + md) % md;
}
inline int add(int a, int b) {
a += b;
if (a >= md) a -= md;
return a;
}
inline int sub(int a, int b) {
a -= b;
if (a < 0) a += md;
return a;
}
inline int mul(int a, int b) {
return (int)((long long)a * b % md);
}
inline int powmod(int a, long long b) {
int res = 1;
while (b > 0) {
if (b & 1) res = mul(res, a);
a = mul(a, a);
b >>= 1;
}
return res;
}
inline int inv(int a) {
a %= md;
if (a < 0) a += md;
int b = md, u = 0, v = 1;
while (a) {
int t = b / a;
b -= t * a; swap(a, b);
u -= t * v; swap(u, v);
}
assert(b == 1);
if (u < 0) u += md;
return u;
}
}
using namespace SimpleModInt;
constexpr int top = 3000 * 3000;
vector<int> fac(top + 1), ifac(top + 1);
int binom(int n, int m) {
if (n < m || n < 0 || m < 0) return 0;
return mul(fac[n], mul(ifac[m], ifac[n - m]));
}
void init() {
fac[0] = 1;
for (int i = 1; i <= top; i++) fac[i] = mul(fac[i - 1], i);
ifac[top] = inv(fac[top]);
for (int i = top; i; i--) ifac[i - 1] = mul(ifac[i], i);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
init();
int n, m, k, res = 0;
cin >> n >> m >> k;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n; j++) {
int cnt = mul(binom((n - i) * (n - j), m), mul(binom(n, i), mul(binom(n, j), binom(i + j, k))));
if ((i + j - k) & 1) {
res = sub(res, cnt);
} else {
res = add(res, cnt);
}
}
}
cout << res;
return 0;
}