2020牛客暑期多校训练营(第一场)

题目传送
F.Infinite String Comparision
单独写了一篇

J.Easy Integration(数学)
题目传送
需要掌握知识点:

分数取模就是分子 * 分母的逆元%mod,分母逆元就为分母^(mod-2)%mod
公式推导结果为:
(n!)^2 / (2 * n + 1)!
AC代码

#include 
inline long long read(){char c = getchar();long long x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x)&(-x)
const int N = 2e6 + 5;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const int mod = 998244353;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
ll dp[N];
ll quick_pow(ll a,ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b&1)
            ans = ans*a%mod;
        b>>=1;
        a = a*a%mod;
    }
    return ans;
}
signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    //    freopen("input.txt","r",stdin);
    //    freopen("output.txt","w",stdout);
    dp[0] = dp[1] = 1;
    for(int i = 2;i <= N;i++)
        dp[i] = dp[i-1]*i%mod;
    ll n;
    while(cin >> n)
        cout << (dp[n]*dp[n]%mod)*quick_pow(dp[2*n+1],mod-2)%mod << endl;
}

你可能感兴趣的:(牛客)