QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#668722 | #8147. Math Exam | bright_ml | ML | 0ms | 0kb | C++20 | 1.0kb | 2024-10-23 15:40:54 | 2024-10-23 15:40:59 |
answer
//
// Created by 35395 on 2024/10/23.
//
#include<bits/stdc++.h>
#define int long long
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] = (mod - mod / i) * inv[mod % i] % mod;
for(int i=1;i<N;i++) f[i] = f[i-1] * i % mod;
for(int i=1;i<N;i++) f_inv[i] = f_inv[i-1] * inv[i] % mod;
}
int C(int a,int b){
if(a < 0 || b < 0 || a < b) return 0;
return 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: 0
Memory Limit Exceeded
input:
9 13
output:
124