QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#74270#3161. Another Coin Weighing PuzzleStarSilkWA 317ms8684kbC++14866b2023-01-31 12:43:012023-01-31 12:43:03

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-31 12:43:03]
  • 评测
  • 测评结果:WA
  • 用时:317ms
  • 内存:8684kb
  • [2023-01-31 12:43:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
long long mod=998244353;
long long qpow(long long a,long long b){
	long long ans=1;
	while(b>0)
	{
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
bool ntprime[1000001]={};
int prime[100000],pricnt=0,N=1000000,val[1000000]={};
void gen(){
	int i,j;
	ntprime[1]=1;
	val[1]=1;
	for(i=2;i<=N;i++)
	{
		if(!ntprime[i])
		{
			prime[pricnt]=i;
			val[i]=-1;
			pricnt++;
		}
		for(j=0;j<pricnt&&i*prime[j]<=N;j++)
		{
			ntprime[i*prime[j]]=1;
			if(i%prime[j]==0)break;
			else val[i*prime[j]]=val[i]*val[prime[j]];
		}
	}
}
int main(int argc, char** argv) {
	ios::sync_with_stdio(false),cin.tie(0);
	int m,k,i,j;
	long long ans=0;
	gen();
	cin>>m>>k;
	for(i=1;i<=k;i++)ans=(ans+val[i]*((qpow(k/i*2+1,m)+mod-1)%mod)+mod)%mod;
	cout<<(ans+1)%mod<<'\n';
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 7ms
memory: 8568kb

input:

2 1

output:

9

result:

ok single line: '9'

Test #2:

score: 0
Accepted
time: 3ms
memory: 8496kb

input:

2 2

output:

17

result:

ok single line: '17'

Test #3:

score: 0
Accepted
time: 11ms
memory: 8680kb

input:

10000 10000

output:

689223145

result:

ok single line: '689223145'

Test #4:

score: 0
Accepted
time: 8ms
memory: 8660kb

input:

9999 31

output:

986106162

result:

ok single line: '986106162'

Test #5:

score: 0
Accepted
time: 4ms
memory: 8508kb

input:

57 9817

output:

447253096

result:

ok single line: '447253096'

Test #6:

score: 0
Accepted
time: 11ms
memory: 8452kb

input:

501 499

output:

247755220

result:

ok single line: '247755220'

Test #7:

score: 0
Accepted
time: 58ms
memory: 8656kb

input:

97424 174829

output:

964884269

result:

ok single line: '964884269'

Test #8:

score: 0
Accepted
time: 12ms
memory: 8512kb

input:

11 13

output:

729153057

result:

ok single line: '729153057'

Test #9:

score: 0
Accepted
time: 62ms
memory: 8492kb

input:

200000 200000

output:

803771125

result:

ok single line: '803771125'

Test #10:

score: 0
Accepted
time: 5ms
memory: 8660kb

input:

199999 562

output:

865836540

result:

ok single line: '865836540'

Test #11:

score: 0
Accepted
time: 42ms
memory: 8540kb

input:

3539 189423

output:

530738158

result:

ok single line: '530738158'

Test #12:

score: 0
Accepted
time: 59ms
memory: 8456kb

input:

198324 173852

output:

963717515

result:

ok single line: '963717515'

Test #13:

score: 0
Accepted
time: 7ms
memory: 8624kb

input:

1 1

output:

3

result:

ok single line: '3'

Test #14:

score: -100
Wrong Answer
time: 317ms
memory: 8684kb

input:

1000000 1000000

output:

421700531

result:

wrong answer 1st lines differ - expected: '800590912', found: '421700531'