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

 

 

 

 

 

 题意:

 

 

思路:

 

 

感觉这个积分我以前是会积的,但是过了一年多的时间,我发现我忘干净了。真是惭愧!

 

 代码:

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int M = 2e6 + 10;
const int mod = 998244353;
LL fac[M];
LL pow_mod(LL a, LL b) {
  LL ans = 1;
  while (b) {
    if (b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
LL inv(LL a) { return pow_mod(a, mod - 2); }
void init() {
  LL p = mod;
  fac[1] = 1;
  for (int i = 2; i <= M; i++) {
    fac[i] = fac[i - 1] * i % p;
  }
}
LL C(LL n, LL m) {
  return fac[m] * pow_mod(fac[n], mod - 2) % mod * pow_mod(fac[m - n], mod - 2) % mod;
}
void solve() {
  LL n;
  init();
  while (~scanf("%lld", &n)) {
    LL ans = 1;
    ans = (n+1) * C(n + 1, n * 2 + 1) % mod;
    printf("%lld\n", inv(ans));
  }
}
int main() {
  solve();
  return 0;
}

 

posted @ 2020-07-17 01:02  sqsq  阅读(179)  评论(0编辑  收藏  举报