結果
問題 | No.1431 東大文系数学2020第2問改 |
ユーザー | 👑 ygussany |
提出日時 | 2021-03-14 14:23:22 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 819 ms / 5,000 ms |
コード長 | 1,129 bytes |
コンパイル時間 | 332 ms |
コンパイル使用メモリ | 32,256 KB |
実行使用メモリ | 142,452 KB |
最終ジャッジ日時 | 2024-04-23 21:52:48 |
合計ジャッジ時間 | 8,760 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 458 ms
142,320 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 424 ms
142,356 KB |
testcase_06 | AC | 125 ms
142,448 KB |
testcase_07 | AC | 125 ms
142,448 KB |
testcase_08 | AC | 175 ms
142,448 KB |
testcase_09 | AC | 815 ms
142,288 KB |
testcase_10 | AC | 326 ms
142,452 KB |
testcase_11 | AC | 126 ms
142,444 KB |
testcase_12 | AC | 419 ms
142,320 KB |
testcase_13 | AC | 213 ms
142,448 KB |
testcase_14 | AC | 239 ms
142,448 KB |
testcase_15 | AC | 203 ms
142,452 KB |
testcase_16 | AC | 148 ms
142,440 KB |
testcase_17 | AC | 126 ms
142,316 KB |
testcase_18 | AC | 126 ms
142,436 KB |
testcase_19 | AC | 819 ms
142,448 KB |
testcase_20 | AC | 128 ms
142,412 KB |
testcase_21 | AC | 525 ms
142,448 KB |
testcase_22 | AC | 144 ms
67,692 KB |
testcase_23 | AC | 819 ms
142,432 KB |
testcase_24 | AC | 790 ms
142,452 KB |
testcase_25 | AC | 1 ms
6,944 KB |
testcase_26 | AC | 2 ms
6,944 KB |
testcase_27 | AC | 1 ms
6,944 KB |
ソースコード
#include <stdio.h> const int Mod = 998244353; long long fact[9000001], fact_inv[9000001]; long long div_mod(long long x, long long y, long long z) { if (x % y == 0) return x / y; else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y; } long long combination(int n, int k) { return fact[n] * fact_inv[k] % Mod * fact_inv[n-k] % Mod; } int main() { int N, M, K; scanf("%d %d %d", &N, &M, &K); int i; for (i = 1, fact[0] = 1; i <= N * N; i++) fact[i] = fact[i-1] * i % Mod; for (i = N * N - 1, fact_inv[N*N] = div_mod(1, fact[N*N], Mod); i >= 0; i--) fact_inv[i] = fact_inv[i+1] * (i + 1) % Mod; int j, k, x, y; long long ans = 0, tmp; for (x = 1; x <= N; x++) { for (y = 1; y <= N; y++) { if (K + x + y > N * 2 || x * y < M) continue; if ((N * 2 - K - x - y) % 2 == 0) ans += combination(x * y, M) * combination(N, x) % Mod * combination(N, y) % Mod * combination(N * 2 - (x + y), K) % Mod; else ans += Mod - combination(x * y, M) * combination(N, x) % Mod * combination(N, y) % Mod * combination(N * 2 - (x + y), K) % Mod; } } printf("%lld\n", ans % Mod); fflush(stdout); return 0; }