QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#290235 | #5817. 小学生数学题 | 50lty12 | 50 | 938ms | 160284kb | C++14 | 603b | 2023-12-24 16:29:44 | 2023-12-24 16:29:45 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mo=998244353,N=2e7+5;
int n,k,ans,a,b;
int s[N];
int qpow(int a,int b){
int ans=1;
for(;b;){
if(b&1) ans=ans*a%mo;
b>>=1;
a=a*a%mo;
}
return ans;
}
signed main(){
s[0]=1;
for(int i=1; i<=2e7; ++i) s[i]=(s[i-1]*i)%mo;
scanf("%lld%lld",&n,&k);
if(k==1){
for(int i=1; i<=n; i++) ans=(ans+s[i-1])%mo;
printf("%lld\n",ans);
return 0;
}
if(k==3){
for(int i=1; i<=n; i=-~i){
a=s[i-1];
b=i*i%mo;
ans+=a*qpow(b,mo-2)%mo;
}
printf("%lld\n",ans%mo);
}
return 0;
}
详细
Test #1:
score: 10
Accepted
time: 117ms
memory: 160064kb
input:
9450395 1
output:
688545438
result:
ok single line: '688545438'
Test #2:
score: 10
Accepted
time: 99ms
memory: 160024kb
input:
8978812 1
output:
334565356
result:
ok single line: '334565356'
Test #3:
score: 10
Accepted
time: 131ms
memory: 160284kb
input:
8944235 1
output:
982802915
result:
ok single line: '982802915'
Test #4:
score: 10
Accepted
time: 865ms
memory: 160172kb
input:
7081118 3
output:
599009773
result:
ok single line: '599009773'
Test #5:
score: 10
Accepted
time: 938ms
memory: 160132kb
input:
7904241 3
output:
871243720
result:
ok single line: '871243720'
Test #6:
score: 0
Time Limit Exceeded
input:
9921275 3
output:
result:
Test #7:
score: 0
Wrong Answer
time: 73ms
memory: 159848kb
input:
17575748 14135489
output:
result:
wrong answer 1st lines differ - expected: '69236780', found: ''
Test #8:
score: 0
Wrong Answer
time: 83ms
memory: 159796kb
input:
19858362 14822524
output:
result:
wrong answer 1st lines differ - expected: '239890381', found: ''
Test #9:
score: 0
Wrong Answer
time: 78ms
memory: 159980kb
input:
18848696 15530895
output:
result:
wrong answer 1st lines differ - expected: '88125041', found: ''
Test #10:
score: 0
Wrong Answer
time: 69ms
memory: 159940kb
input:
17787945 13890407
output:
result:
wrong answer 1st lines differ - expected: '989967864', found: ''