J-Easy Intergration

Easy Integration

https://ac.nowcoder.com/acm/contest/5666/J

链接:https://ac.nowcoder.com/acm/contest/5666/J
来源:牛客网

题目描述:

Given n,find the value of 图片说明
It can be proved that the value is a rational number 图片说明 .
Print the result as ( 图片说明 ) 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≤1e6
The number of test cases does not exceed 1e5

输出描述:

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

solution:

先将函数变成x*(1-x),然后将(1-x)的n次二项式展开,对展开后的函数进行积分,就可以将函数积分出来的公式写出来,然后进行找规律,找出的规律是在前一项上除以一个数,再乘以两个数(具体什么我已经忘了),找规律过程中不要化简,不然找不到规律

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
const int mod=998244353;
ll extend_gcd(ll a,ll b, ll&x,ll &y)
{
    if(a==0&&b==0)return -1;
    if(b==0){x=1;y=0;return a;}
    ll d=extend_gcd(b,a%b,y,x);
    y-=a/b*x;
    return d;
}
ll mod_reverse(ll a,ll n)
{
    ll x,y;
    ll d=extend_gcd(a,n,x,y);
    if(d==1)return (x%n+n)%n;
    else return -1;
}
ll a[2000005];
ll b[2000005];
ll c[2000005];
ll t=4;
int main()
{
    a[1]=1;
    b[1]=6;
    c[1]=1;
    for(int i=2;i<=1000000;i++)
    {
        a[i]=a[i-1]*i%mod;//cout<<a[i]<<endl;
        b[i]=b[i-1]*(t*(t+1)%mod)%mod;
        c[i]=c[i-1]*i%mod;
        t+=2;
    }
    while(~scanf("%d",&n))
    {
        ll s=mod_reverse(b[n],mod)*(a[n]*c[n]%mod)%mod;
        printf("%lld\n",s);
    }
}
全部评论

相关推荐

后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
无实习如何秋招上岸
点赞 评论 收藏
分享
05-12 17:00
门头沟学院 Java
king122:你的项目描述至少要分点呀,要实习的话,你的描述可以使用什么技术,实现了什么难点,达成了哪些数字指标,这个数字指标尽量是真实的,这样面试应该会多很多,就这样自己包装一下,包装不好可以找我,我有几个大厂最近做过的实习项目也可以包装一下
点赞 评论 收藏
分享
投递长鑫存储等公司8个岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务