第一种方法,直接用分部积分的算法,递推下去,最后可以得到结果
书写潦草,大致写法
方法二: 直接调用贝塔函数,对比系数法,就可以的到公式
对于 p/q % mod 这种,当mod为奇数的时候,就可以用快速幂方法求逆元
代码:
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const double eps = 1e-4;
const int mod = 998244353;
const int N = 2000010;
int fact[N],infact[N];
int qmi(int a,int b){
int res = 1;
while(b){
if(b&1) res = res*a%mod;
a = a*a%mod;
b >>= 1;
}
return res;
}
void init(){//这里不用infact存,直接求逆元更快qmi(fact[2*n+1],mod-2)
fact[0] = infact[0] = 1;
for(int i=1;i<N;i++){
fact[i] = fact[i-1]*i%mod;
infact[i] = infact[i-1]*qmi(i,mod-2)%mod;
}
}
signed main(){
// IOS;
#ifdef ddgo
freopen("C:/Users/asus/Desktop/ddgoin.txt","r",stdin);
#endif
int n;
init();
while(cin >>n)
cout<<fact[n]*fact[n]%mod*infact[2*n+1]%mod<<endl;
return 0;
}