QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#668722#8147. Math Exambright_mlML 0ms0kbC++201.0kb2024-10-23 15:40:542024-10-23 15:40:59

Judging History

你现在查看的是最新测评结果

  • [2024-10-23 15:40:59]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:0kb
  • [2024-10-23 15:40:54]
  • 提交

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';
}

详细

Test #1:

score: 0
Memory Limit Exceeded

input:

9 13

output:

124

result: