2020 Niuke Summer Multi-School Training Camp (First Session) J Easy Integration


At the beginning of 2020/7/13, I thought that as long as the number of integrations and the preprocessing factorial were calculated, the O(n) calculation result would be enough. Later, I found out that I would have to O(1). No way, I found the formula on OEIS on the table-I actually found it. .
Here is the real process:
Insert picture description here
Triangulation for Yuan Dafa nb! I don't know how to goose, but Gaoshu Caiji is here. It seems to be "Wallis' integrals".
Get the formula, the code is natural. . . A simple inverse is enough:

#include<bits/stdc++.h>
using namespace std;
#define M 2000010
#define mod 998244353
int n,f[M],g[M],inv[M];
int main(){
    
    
    f[1]=g[1]=inv[1]=1;
    for(int i=2;i<2000005;i++){
    
    
        f[i]=1ll*f[i-1]*i%mod;
        inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
        g[i]=1ll*g[i-1]*inv[i]%mod;
    }
    while(~scanf("%d",&n))printf("%d\n",1ll*g[2*n+1]*f[n]%mod*f[n]%mod);
    return 0;
}

Guess you like

Origin blog.csdn.net/ylwhxht/article/details/107454510