QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#674720 | #6736. Alice and Bob | wysun | WA | 0ms | 3584kb | C++14 | 849b | 2024-10-25 17:18:36 | 2024-10-25 17:18:36 |
Judging History
answer
#include <iostream>
#include<vector>
using namespace std;
using i64 = long long;
const int P = 998244353;
int power(int a, int b)
{
int res = 1;
while(b)
{
if(b & 1) res = (i64)res * a % P;
a = (i64)a * a % P;
b >>= 1;
}
return res;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> fac(n + 1), invfac(n + 1);
fac[0] = 1;
for (int i = 1; i <= n; i ++)
fac[i] = 1ll * fac[i - 1] * i % P;
invfac[n] = power(fac[n], P - 2);
for(int i = n - 1; i > 0; i --)
invfac[i] = 1ll * invfac[i + 1] * (i + 1) % P;
int ans = 0;
for (int i = 1; n - i >= i - 1; i++)
ans = (ans + 1LL * fac[n - i] * invfac[n - i - (i - 1)] % P * fac[n - i]) % P;
cout << ans << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
1
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'