QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#399141 | #6736. Alice and Bob | qionghua | WA | 1ms | 5728kb | C++20 | 1.5kb | 2024-04-25 22:58:40 | 2024-04-25 22:58:44 |
Judging History
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
// 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};
int ksm(int a, int b, int p) {
int ans = 1;
while(b) {
if(b & 1) ans = 1ll * ans * a % p;
b >>= 1;
a = 1ll * a * a % p;
}
return ans;
}
const int N = 1e7 + 1;
int f[N], g[N];
void init(int n) {
f[0] = g[0] = f[1] = g[1] = 1;
for(int i = 2; i <= n; ++ i ) {
f[i] = 1ll * f[i - 1] * i % pp;
if (n & 1 && (i % 2 == 0)) g[i] = 1ll * g[i - 1] * ksm(i, pp - 2, pp) % pp;
if ((n % 2 == 0) && i & 1) g[i] = 1ll * g[i - 1] * ksm(i, pp - 2, pp) % pp;
}
}
void solve() {
int n;
cin >> n;
init(n);
int ans = 0;
for(int p1 = 1; p1 <= n / 2 + 1; ++ p1) {
int now = 1ll * g[n - p1 - p1 + 1] * f[n - p1] % 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);
int _ = 1;
// cin >> _;
while(_ -- ) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5724kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 5716kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 5728kb
input:
10
output:
14400
result:
wrong answer 1st numbers differ - expected: '997920', found: '14400'