QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#317557 | #8147. Math Exam | PetroTarnavskyi | AC ✓ | 132ms | 89636kb | C++20 | 1.6kb | 2024-01-29 05:38:23 | 2024-01-29 05:38:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); i--)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int mod = 998244353;
int add(int a, int b)
{
return a + b < mod ? a + b : a + b - mod;
}
int sub(int a, int b)
{
return a - b >= 0 ? a - b : a - b + mod;
}
int mult(int a, int b)
{
return (LL)a * b % mod;
}
int binpow(int a, int n)
{
int res = 1;
while(n)
{
if(n & 1)
res = mult(res, a);
a = mult(a, a);
n /= 2;
}
return res;
}
const int N = 1.1e7;
int fact[N], ifact[N];
void init()
{
fact[0] = 1;
FOR(i, 1, N)
fact[i] = mult(fact[i - 1], i);
ifact[N - 1] = binpow(fact[N - 1], mod - 2);
RFOR(i, N, 1)
ifact[i - 1] = mult(ifact[i], i);
}
int C(int n, int k)
{
if(k < 0 || k > n)
return 0;
return mult(fact[n], mult(ifact[k], ifact[n - k]));
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(15);
init();
int n, m;
cin >> n >> m;
m = (m + 1) / 2;
int ans = 0;
int l1 = -1, l2 = m + 1;
int len = l2 - l1;
int mo = 2 * len;
FOR(i, 0, n + 1)
{
int h = i - (n - i);
int val = C(n, i);
h = (h % mo + mo) % mo;
if(h == mo - 1 || h == l2)
continue;
if(h < l2)
ans = add(ans, val);
else
ans = sub(ans, val);
}
cout << ans << "\n";
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 95ms
memory: 89632kb
input:
9 13
output:
124
result:
ok answer is '124'
Test #2:
score: 0
Accepted
time: 109ms
memory: 89612kb
input:
500 999
output:
195157058
result:
ok answer is '195157058'
Test #3:
score: 0
Accepted
time: 132ms
memory: 89572kb
input:
10000000 19260817
output:
475124613
result:
ok answer is '475124613'
Test #4:
score: 0
Accepted
time: 105ms
memory: 89560kb
input:
1234567 654321
output:
986926700
result:
ok answer is '986926700'
Test #5:
score: 0
Accepted
time: 109ms
memory: 89544kb
input:
1145141 11451
output:
186897097
result:
ok answer is '186897097'
Test #6:
score: 0
Accepted
time: 106ms
memory: 89624kb
input:
114514 11451
output:
91839230
result:
ok answer is '91839230'
Test #7:
score: 0
Accepted
time: 110ms
memory: 89572kb
input:
1145143 114555
output:
641840034
result:
ok answer is '641840034'
Test #8:
score: 0
Accepted
time: 103ms
memory: 89516kb
input:
2123181 1980523
output:
784155222
result:
ok answer is '784155222'
Test #9:
score: 0
Accepted
time: 122ms
memory: 89572kb
input:
4238693 1876847
output:
169222558
result:
ok answer is '169222558'
Test #10:
score: 0
Accepted
time: 127ms
memory: 89504kb
input:
7804655 10519823
output:
935955279
result:
ok answer is '935955279'
Test #11:
score: 0
Accepted
time: 132ms
memory: 89616kb
input:
9189568 17055313
output:
811181659
result:
ok answer is '811181659'
Test #12:
score: 0
Accepted
time: 96ms
memory: 89504kb
input:
683534 1001003
output:
569208897
result:
ok answer is '569208897'
Test #13:
score: 0
Accepted
time: 94ms
memory: 89636kb
input:
1850342 3700683
output:
852266054
result:
ok answer is '852266054'
Test #14:
score: 0
Accepted
time: 127ms
memory: 89508kb
input:
10000000 1234567
output:
387622638
result:
ok answer is '387622638'
Test #15:
score: 0
Accepted
time: 74ms
memory: 89480kb
input:
1 1
output:
1
result:
ok answer is '1'
Test #16:
score: 0
Accepted
time: 104ms
memory: 89476kb
input:
3 1
output:
1
result:
ok answer is '1'
Test #17:
score: 0
Accepted
time: 129ms
memory: 89528kb
input:
10000000 1
output:
1
result:
ok answer is '1'
Extra Test:
score: 0
Extra Test Passed