QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#668729 | #8147. Math Exam | bright_ml | WA | 381ms | 238068kb | C++20 | 1.0kb | 2024-10-23 15:42:34 | 2024-10-23 15:42:35 |
Judging History
answer
//
// Created by 35395 on 2024/10/23.
//
#include<bits/stdc++.h>
using namespace std;
const int N = 2e7 + 100, mod = 998244353;
int f[N],f_inv[N],inv[N];
void init(){
inv[1] = f[0] = f_inv[0] = 1;
for(int i=2;i<N;i++) inv[i] = 1ll*(mod - mod / i) * inv[mod % i] % mod;
for(int i=1;i<N;i++) f[i] = 1ll*f[i-1] * i % mod;
for(int i=1;i<N;i++) f_inv[i] = 1ll*f_inv[i-1] * inv[i] % mod;
}
int C(int a,int b){
if(a < 0 || b < 0 || a < b) return 0;
return 1ll*f[a] * f_inv[b] % mod * f_inv[a-b] % mod;
}
int n,m;
pair<int,int> get(int x,int y,int c){
return {y-c,x+c};
}
signed main(){
init();
cin >> n >> m;
int down = (n + 1) / 2;
int ans = 0;
int c = -(m+1)/2 - 1;
for(int i=down;i<=n && i <= n-i+(m+1)/2;i++){
int j = n - i;
auto [i_,j_] = get(i,j,1);
auto [_i,_j] = get(i,j,c);
auto [ii,jj] = get(i_,j_,c);
ans += C(n,i) - C(n,_i) - C(n,i_) + C(n,ii);
ans = (ans % mod + mod) % mod;
}
cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 339ms
memory: 237980kb
input:
9 13
output:
124
result:
ok answer is '124'
Test #2:
score: 0
Accepted
time: 312ms
memory: 237880kb
input:
500 999
output:
195157058
result:
ok answer is '195157058'
Test #3:
score: -100
Wrong Answer
time: 381ms
memory: 238068kb
input:
10000000 19260817
output:
503086045
result:
wrong answer expected '475124613', found '503086045'