Submission #2140482
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using s64 = long long;
const int MaxN = 500000;
const int MaxM = 500000;
const int M = 998244353;
inline int modpow(int a, const int &n)
{
int res = 1;
for (int i = n; i; i >>= 1)
{
if (i & 1)
res = (s64)res * a % M;
a = (s64)a * a % M;
}
return res;
}
int n, m;
int fact[MaxM + 1];
int rfact[MaxM + 1];
inline int binom(int n, int m)
{
return m < 0 ? 0 : (s64)fact[n] * rfact[m] % M * rfact[n - m] % M;
}
int main()
{
cin >> n >> m;
fact[0] = 1;
for (int i = 1; i <= m; ++i)
fact[i] = (s64)fact[i - 1] * i % M;
rfact[m] = modpow(fact[m], M - 2);
for (int i = m; i; --i)
rfact[i - 1] = (s64)rfact[i] * i % M;
int res = 0;
for (int i = max(n, (m + 1) / 2); i <= m; ++i)
{
int j = m - i - (i * 2 == m);
int t = i - n + 1;
res = (res + binom(i + j, j) - binom(i + j, j - t)) % M;
}
cout << (res + M) % M << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Ball Eat Chameleons |
| User | InvUsr |
| Language | C++14 (GCC 5.4.1) |
| Score | 1200 |
| Code Size | 965 Byte |
| Status | AC |
| Exec Time | 10 ms |
| Memory | 4224 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 1200 / 1200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | s1.txt, s2.txt, s3.txt, s4.txt, s5.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, s1.txt, s2.txt, s3.txt, s4.txt, s5.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 7 ms | 4096 KiB |
| 02.txt | AC | 10 ms | 4096 KiB |
| 03.txt | AC | 9 ms | 4096 KiB |
| 04.txt | AC | 8 ms | 4096 KiB |
| 05.txt | AC | 7 ms | 4096 KiB |
| 06.txt | AC | 4 ms | 2048 KiB |
| 07.txt | AC | 2 ms | 512 KiB |
| 08.txt | AC | 3 ms | 1152 KiB |
| 09.txt | AC | 6 ms | 3200 KiB |
| 10.txt | AC | 7 ms | 4096 KiB |
| 11.txt | AC | 8 ms | 3712 KiB |
| 12.txt | AC | 8 ms | 3840 KiB |
| 13.txt | AC | 8 ms | 4096 KiB |
| 14.txt | AC | 9 ms | 4096 KiB |
| 15.txt | AC | 8 ms | 3328 KiB |
| 16.txt | AC | 7 ms | 4096 KiB |
| 17.txt | AC | 7 ms | 4096 KiB |
| 18.txt | AC | 7 ms | 4096 KiB |
| 19.txt | AC | 7 ms | 4096 KiB |
| 20.txt | AC | 8 ms | 3712 KiB |
| 21.txt | AC | 9 ms | 4096 KiB |
| 22.txt | AC | 7 ms | 2816 KiB |
| 23.txt | AC | 1 ms | 256 KiB |
| 24.txt | AC | 6 ms | 3328 KiB |
| 25.txt | AC | 6 ms | 3328 KiB |
| 26.txt | AC | 10 ms | 4096 KiB |
| 27.txt | AC | 10 ms | 4224 KiB |
| 28.txt | AC | 10 ms | 4096 KiB |
| 29.txt | AC | 1 ms | 256 KiB |
| 30.txt | AC | 1 ms | 256 KiB |
| 31.txt | AC | 1 ms | 256 KiB |
| 32.txt | AC | 1 ms | 256 KiB |
| 33.txt | AC | 9 ms | 4096 KiB |
| 34.txt | AC | 7 ms | 3072 KiB |
| s1.txt | AC | 1 ms | 256 KiB |
| s2.txt | AC | 1 ms | 256 KiB |
| s3.txt | AC | 1 ms | 256 KiB |
| s4.txt | AC | 1 ms | 256 KiB |
| s5.txt | AC | 5 ms | 2048 KiB |