2020牛客暑假多校第一场 J题 Easy Integration
Posted lasomisolaso~
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2020牛客暑假多校第一场 J题 Easy Integration相关的知识,希望对你有一定的参考价值。
题意:
思路:
开始是把式子用二项式定理展开,之后各项积分,复杂度为
O
(
n
)
O(n)
O(n).之后发现多组样例,时间复杂度就不可行了。之后就上OEIS了。。。
赛后参照网上网上的题解,需要用
n
n
n次分部积分。
分部积分公式:
n
n
n次之后
(
1
−
x
)
(1 - x)
(1−x)的指数就变成了
0
0
0,那么积分就是
1
1
1了,然后只要考虑前面的系数就可以了。
/*
* @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;
以上是关于2020牛客暑假多校第一场 J题 Easy Integration的主要内容,如果未能解决你的问题,请参考以下文章
杭电2018多校第一场(2018 Multi-University Training Contest 1) 1001.Maximum Multiple (HDU6298)-数学思维题(脑子是个好东西,