2020牛客暑期多校第一场J题
程序员文章站
2022-06-02 22:17:10
...
牛客多校暑期第一场J题:
题目:
AC代码:
using namespace std;
typedef long long ll;
const int MOD = 998244353;
ll inv[2000001];
void pre(int MOD){
inv[0] = inv[1]=1;
for(int i = 2; i < 2000001; i++)
inv[i] = ((MOD - MOD / i) * inv[MOD % i]) % MOD;
}
long long quick_pow(long long n, long long p, long long k){
long long ans = 1;
while(p){
if(p & 1) ans = (ans % k * n % k) % k;
p >>= 1;
n = (n % k * n % k) % k;
}
return ans % k;
}
ll xxx[2000001];
void solve(){
ll temp = 1;
for(int i = 1; i <= 2000000; i++){
temp = temp * i % MOD;
xxx[i] = temp;
}
}
int main(){
solve();
ll n;
while(~scanf("%lld", &n)){
ll fenzi = 1;
ll fenmu = 1;
fenmu = xxx[2 * n + 1];
fenzi = xxx[n] * xxx[n] % MOD;
cout << quick_pow(fenmu, MOD - 2, MOD) * fenzi % MOD << endl;
}
return 0;
}
推荐阅读
-
2020牛客暑期多校训练营(第四场)——Basic Gcd Problem
-
2020牛客暑期多校训练营(第五场)
-
2020牛客暑期多校训练营(第九场) The Flee Plan of Groundhog
-
2020牛客暑期多校训练营Groundhog and Apple Tree(树形dp,贪心)
-
2020暑期牛客多校训练营第九场(K)The Flee Plan of Groundhog(lca,树形dp)
-
2020牛客多校第三场-J Just Shuffle
-
2020牛客多校第3场[Clam and Fish+贪心]
-
2020牛客多校第三场 E Two Matchings
-
2020牛客暑期多校训练营(第二场)Cover the Tree
-
2020牛客暑期多校训练营(第一场)H-Minimum-cost Flow