Easy Integration


Easy Integration

题目大意

Given n, find the value of ∫ 0 1 ( x − x 2 ) n d x \int_{0}^1 (x - x^2)^n \mathrm{d} x 01(xx2)ndx
It can be proved that the value is a rational number p q \frac{p}{q} qp.
Print the result as ( p ⋅ q − 1 )   m o d   p \cdot q^{-1}) \bmod pq1)mod 998244353.

输入描述:

The input consists of several test cases and is terminated by end-of-file.
Each test case contains an integer n.

  • 1 ≤ n ≤ 1 0 6 \leq n \leq 10^6 n106
  • The number of test cases does not exceed 10 5 ^5 5

输出描述:

For each test case, print an integer which denotes the result.

输入样例

1
2
3

输出样例

166374059
432572553
591816295

For n = 1, ∫ 0 1 ( x − x 2 ) d x = x 2 2 − x 3 3 ∣ 0 1 \int_{0}^1 (x - x^2) \mathrm{d} x = \frac{x^2}{2} - \frac{x^3}{3} |_0^1 01(xx2)dx=2x23x301 = 1 6 \frac{1}{6} 61
求一下逆元
X=166374059,a=1,b=6;
a/b mod 998244353==X
a mod 998244353 == b*X mod 998244353

oeis

#include <cstdio>
#include <algorithm>
#define rep(i,a,b) for(auto i=a;i<=b;++i)
using namespace std;
typedef long long ll;
const int mod=998244353,maxn=1e6+7;
ll a[maxn<<1],b[maxn<<1],inv[maxn<<1];
int main()
{
    int n;
    a[0]=b[0]=b[1]=inv[1]=inv[0]=1;
    rep(i,1,maxn<<1){
        a[i]=a[i-1]*i%mod;
        if(i>1) inv[i]=(mod-mod/i)*inv[mod%i]%mod,b[i]=b[i-1]*inv[i]%mod;
    }
    while(~scanf("%d",&n))
        printf("%lld\n",((a[n]%mod*a[n]%mod*b[(n<<1)+1]%mod)+mod)%mod);
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

幸愉聊信奥

谢谢亲的支持,我会继续努力啦~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值