QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#393489 | #6736. Alice and Bob | wakakaka | WA | 1ms | 3612kb | C++17 | 1.0kb | 2024-04-18 17:15:36 | 2024-04-18 17:15:36 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define PSI pair<string,int>
#define double long double
const int mod=998244353;
using namespace std;
int ksm(int a,int b){
int ans=1;
while(b){
if(b&1) {
ans*=a;
ans%=mod;
}
a*=a;
a%=mod;
b>>=1;
}
return ans;
}
void solve() {
int n;
cin>>n;
vector<int>fac(n+1);
int ans=0;
fac[0]=1;
for (int i = 1; i <=n ; ++i) {
fac[i]=(fac[i-1]*i)%mod;
}
if(n==1) {
cout << 1 << endl;
return ;
}
for (int i = 1; i <n ; ++i) {
int res=fac[n-i]%mod;
res%=mod;
res*=ksm(fac[(n-2*i)+1],mod-2)%mod;
res%=mod;
res*=fac[n-i];
res%=mod;
ans+=res;
ans%=mod;
}
cout<<ans<<endl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0) , cout.tie(0);
int T = 1;
//cin >> T ;
while(T--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3612kb
input:
1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3612kb
input:
10
output:
793418701
result:
wrong answer 1st numbers differ - expected: '997920', found: '793418701'