QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#398623 | #6736. Alice and Bob | yeVegeTable# | TL | 0ms | 0kb | C++20 | 1.7kb | 2024-04-25 15:53:15 | 2024-04-25 15:53:17 |
answer
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
#define endl '\n'
//#define inf 1e18
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
typedef pair<ll, ll> P;
#define x first
#define y second
#define int long long
// const int p = 1e9 + 7;
const int pp = 998244353;
int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1}, dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
int ddx[8] = {1, 1, 2, 2, -1, -1, -2, -2}, ddy[8] = {2, -2, 1, -1, 2, -2, 1, -1};
ll ksm(ll a, ll b, ll p) {
ll ans = 1;
while(b) {
if(b & 1) ans = (ans * a) % p;
b >>= 1;
a = (a * a) % p;
}
return ans % p;
}
std::mt19937 rng; // 随机数生成器
int rand(int l, int r) {
std::uniform_int_distribution<int> distribution(l, r);
return distribution(rng);
}
const int N = 1e7 + 1;
int f[N], g[N];
void init() {
f[0] = g[0] = f[1] = g[1] = 1;
for(int i = 2; i <= N; i++) {
f[i] = f[i - 1] * i % pp;
g[i] = g[i - 1] * ksm(i, pp - 2, pp) % pp;
}
}
int C(int a, int b) {
if(a < b) return 0;
return f[a] * g[b] % pp * g[a - b] % pp;
}
void solve() {
int n;
cin >> n;
int ans = 0;
for(int p1 = 1; p1 <= n / 2 + 1; p1++) {
int now = C(n - p1, p1 - 1) * f[p1 - 1] % pp * f[n - p1] % pp;
// cout << "p1 : " << p1 << ", now : " << now << endl;
ans = (ans + now) % pp;
}
cout << ans << endl;
}
/*
*/
signed main () {
// init(minp, primes, m); // primes
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
init();
int _ = 1;
// cin >> _;
while(_ -- ) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
1