QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#290235#5817. 小学生数学题50lty1250 938ms160284kbC++14603b2023-12-24 16:29:442023-12-24 16:29:45

Judging History

你现在查看的是最新测评结果

  • [2023-12-24 16:29:45]
  • 评测
  • 测评结果:50
  • 用时:938ms
  • 内存:160284kb
  • [2023-12-24 16:29:44]
  • 提交

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: ''