QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#287982#5817. 小学生数学题Haoyue_0643260 629ms120556kbC++14718b2023-12-21 13:46:472023-12-21 13:46:47

Judging History

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

  • [2023-12-21 13:46:47]
  • 评测
  • 测评结果:60
  • 用时:629ms
  • 内存:120556kb
  • [2023-12-21 13:46:47]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define maxn 20000005
#define inf 1e18
#define mod 998244353
using namespace std;
ll n,m,ans1=1,inv[maxn],zs[maxn],cnt,ans;
bool bj[maxn];
ll ksm(ll x,ll y)
{
	ll ans=1;
	while(y)
	{
		if(y%2==1)ans=(ans*x)%mod;
		x=(x*x)%mod;
		y/=2;
	}
	return ans;
}
int main()
{
	cin>>n>>m;
	inv[1]=1;
	for(int i=2;i<=n;i++)
	{
		if(!bj[i])
		{
			bj[i]=true;
			inv[i]=ksm(ksm(i,m),mod-2);
			for(int j=1;j<=cnt&&zs[j]*i<=n;j++)
			{
				bj[zs[j]*i]=true;
				inv[zs[j]*i]=(inv[zs[j]]*inv[i])%mod;
			}
			zs[++cnt]=i;
		}
	}
	for(int i=1;i<=n;i++)
	{
		ans1=(ans1*i)%mod;
		ans=(ans+ans1*inv[i]%mod)%mod;
	}
	cout<<ans;
	return 0;
}
/*
*/

详细

Test #1:

score: 10
Accepted
time: 590ms
memory: 115348kb

input:

9450395 1

output:

688545438

result:

ok single line: '688545438'

Test #2:

score: 10
Accepted
time: 558ms
memory: 110876kb

input:

8978812 1

output:

334565356

result:

ok single line: '334565356'

Test #3:

score: 10
Accepted
time: 550ms
memory: 109416kb

input:

8944235 1

output:

982802915

result:

ok single line: '982802915'

Test #4:

score: 10
Accepted
time: 447ms
memory: 87432kb

input:

7081118 3

output:

599009773

result:

ok single line: '599009773'

Test #5:

score: 10
Accepted
time: 478ms
memory: 97916kb

input:

7904241 3

output:

871243720

result:

ok single line: '871243720'

Test #6:

score: 10
Accepted
time: 629ms
memory: 120556kb

input:

9921275 3

output:

549818101

result:

ok single line: '549818101'

Test #7:

score: 0
Time Limit Exceeded

input:

17575748 14135489

output:


result:


Test #8:

score: 0
Time Limit Exceeded

input:

19858362 14822524

output:


result:


Test #9:

score: 0
Time Limit Exceeded

input:

18848696 15530895

output:


result:


Test #10:

score: 0
Time Limit Exceeded

input:

17787945 13890407

output:


result: