2020牛客暑假多校第一场 【J题 Easy Integration】
程序员文章站
2024-03-17 20:17:28
...
题意:
思路:
开始是把式子用二项式定理展开,之后各项积分,复杂度为.之后发现多组样例,时间复杂度就不可行了。之后就上OEIS了。。。
赛后参照网上网上的题解,需要用次分部积分。
分部积分公式:
次之后的指数就变成了,那么积分就是了,然后只要考虑前面的系数就可以了。
/*
* @file J.cpp
* @path D:\code\ACM\牛客多校\第一场\J.cpp
* @author Xiuchen
* @date 2020-07-12 13:50:22
*/
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<cmath>
#include<math.h>
#include<iostream>
#include<algorithm>
//#define DEBUG
#define dbg(x) cout << #x << " = "<< (x) << endl
#define dbg2(x1,x2) cout << #x1 << " = " << x1 << " " << #x2 << " = " << x2 << endl
#define dbg3(x1,x2,x3) cout<< #x1 << " = " << x1 << " " << #x2 << " = " << x2 << " " << #x3 << " = " << x3 <<endl
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 998244353;
const int maxn = 2e6 + 100;
int gcd(int a, int b){
return b ? gcd(b, a % b) : a;
}
ll qpow(ll a, ll b){
ll ans = 1, base = a;
while(b){
if(b & 1) ans = ans * base % mod;
base = base * base % mod;
b >>= 1;
}
return ans;
}
int n;
ll jc[maxn], jc_inv[maxn];
ll inv[maxn], preans[maxn];
int main(){
#ifdef DEBUG
freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
jc[0] = 1, jc_inv[0] = 1;
for(int i = 1; i <= 2000001; i++) inv[i] = qpow(i, mod - 2);
for(int i = 1; i <= 2000001; i++) jc[i] = jc[i - 1] * i % mod;
for(int i = 1; i <= 2000001; i++) jc_inv[i] = jc_inv[i - 1] * inv[i] % mod;
// memset(preans, -1, sizeof(preans));
while(~scanf("%d", &n)){
ll ans = jc[n] * jc[n] % mod;
ans = ans * jc_inv[2 * n + 1] % mod;
printf("%lld\n", ans);
}
return 0;
}