Submission #72408015
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using LL = long long;
using pii = pair<int, int>;
#define fi first
#define se second
constexpr int MAXN = 2e7 + 5, mod = 998244353;
inline void inc(int &x, int y) { (x += y) >= mod && (x -= mod); }
inline void dec(int &x, int y) { (x -= y) < 0 && (x += mod); }
inline void tim(int &x, int y) { x = (LL)x * y % mod; }
inline int madd(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int msub(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }
inline int mmul(int x, int y) { return (LL)x * y % mod; }
inline int qpow(int x, int y = mod - 2) {
int ret = 1;
while (y) {
if (y & 1) tim(ret, x);
tim(x, x), y >>= 1;
}
return ret;
}
int n, m, fac[MAXN], invf[MAXN];
inline int binom(int N, int M) {
if (N < M || N < 0 || M < 0) return 0;
return (LL)fac[N] * invf[M] % mod * invf[N - M] % mod;
}
inline int calc(int N, int M) {
return binom(N + M - 1, M * 2 - 1);
}
int main() {
IOS;
cin >> n >> m;
if (n < m) {
cout << "0\n";
return 0;
}
fac[0] = 1;
for (int i = 1; i <= n + m; ++i) fac[i] = mmul(fac[i - 1], i);
invf[n + m] = qpow(fac[n + m]);
for (int i = n + m; i >= 1; --i) invf[i - 1] = mmul(invf[i], i);
int ans = 0;
for (int i = 0; i <= n; ++i) {
int j = n - i;
if (i < j) continue;
inc(ans, (LL)binom(j + m - 1, m - 1) * calc(i - j, m) % mod);
}
cout << mmul(ans, qpow(2, m));
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - ABS Ball |
| User | EnderLwz |
| Language | C++23 (GCC 15.2.0) |
| Score | 600 |
| Code Size | 1521 Byte |
| Status | AC |
| Exec Time | 242 ms |
| Memory | 159944 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 600 / 600 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_min_01.txt, 01_min_02.txt, 01_min_03.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 03_random_01.txt, 03_random_02.txt, 03_random_03.txt, 03_random_04.txt, 03_random_05.txt, 03_random_06.txt, 03_random_07.txt, 03_random_08.txt, 03_random_09.txt, 03_random_10.txt, 03_random_11.txt, 03_random_12.txt, 03_random_13.txt, 03_random_14.txt, 03_random_15.txt, 04_max_01.txt, 04_max_02.txt, 04_max_03.txt, 04_max_04.txt, 04_max_05.txt, 04_max_06.txt, 05_n_large_01.txt, 05_n_large_02.txt, 05_n_large_03.txt, 05_n_large_04.txt, 05_n_large_05.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_01.txt | AC | 1 ms | 3660 KiB |
| 00_sample_02.txt | AC | 1 ms | 3652 KiB |
| 00_sample_03.txt | AC | 192 ms | 120880 KiB |
| 01_min_01.txt | AC | 1 ms | 3420 KiB |
| 01_min_02.txt | AC | 1 ms | 3404 KiB |
| 01_min_03.txt | AC | 1 ms | 3708 KiB |
| 02_small_01.txt | AC | 1 ms | 3640 KiB |
| 02_small_02.txt | AC | 1 ms | 3592 KiB |
| 02_small_03.txt | AC | 1 ms | 3456 KiB |
| 02_small_04.txt | AC | 1 ms | 3628 KiB |
| 02_small_05.txt | AC | 1 ms | 3712 KiB |
| 03_random_01.txt | AC | 1 ms | 3536 KiB |
| 03_random_02.txt | AC | 176 ms | 106536 KiB |
| 03_random_03.txt | AC | 21 ms | 15192 KiB |
| 03_random_04.txt | AC | 175 ms | 107420 KiB |
| 03_random_05.txt | AC | 112 ms | 70488 KiB |
| 03_random_06.txt | AC | 53 ms | 35072 KiB |
| 03_random_07.txt | AC | 137 ms | 86960 KiB |
| 03_random_08.txt | AC | 208 ms | 137800 KiB |
| 03_random_09.txt | AC | 169 ms | 106740 KiB |
| 03_random_10.txt | AC | 1 ms | 3680 KiB |
| 03_random_11.txt | AC | 1 ms | 3652 KiB |
| 03_random_12.txt | AC | 147 ms | 85580 KiB |
| 03_random_13.txt | AC | 158 ms | 96120 KiB |
| 03_random_14.txt | AC | 13 ms | 10484 KiB |
| 03_random_15.txt | AC | 1 ms | 3636 KiB |
| 04_max_01.txt | AC | 242 ms | 159800 KiB |
| 04_max_02.txt | AC | 145 ms | 81780 KiB |
| 04_max_03.txt | AC | 241 ms | 159944 KiB |
| 04_max_04.txt | AC | 190 ms | 120720 KiB |
| 04_max_05.txt | AC | 237 ms | 159944 KiB |
| 04_max_06.txt | AC | 155 ms | 90012 KiB |
| 05_n_large_01.txt | AC | 144 ms | 81920 KiB |
| 05_n_large_02.txt | AC | 148 ms | 81664 KiB |
| 05_n_large_03.txt | AC | 147 ms | 81616 KiB |
| 05_n_large_04.txt | AC | 145 ms | 81600 KiB |
| 05_n_large_05.txt | AC | 146 ms | 82304 KiB |