QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#74441#3161. Another Coin Weighing Puzzle541foreverWA 3ms5428kbC++14856b2023-02-01 19:29:212023-02-01 19:29:24

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-01 19:29:24]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:5428kb
  • [2023-02-01 19:29:21]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN=1000000,mod=998244353;
int m,k,mu[MAXN+5],pri[MAXN+5],tot,no[MAXN+5];
int MUL(int x,int y){
	return (long long)x*y%mod;
}
int poww(int x,int y){
	int sum=1;
	while(y){
		if(y&1){
			sum=MUL(sum,x);
		}
		x=MUL(x,x);
		y>>=1;
	}
	return sum;
}
void prep(){
	mu[1]=1;
	for(int i=2;i<=k;++i){
		if(!no[i]){
			pri[++tot]=i;
			mu[i]=-1;
		}
		for(int j=1;j<=tot;++j){
			if((long long)pri[j]*i>k){
				break;
			}
			no[pri[j]*i]=1;
			if(i%pri[j]==0){
				mu[i]=0;
				break;
			}
			mu[i*pri[j]]=-mu[i];
		}
	}
}
signed main(){
	ios::sync_with_stdio(false);
	cin>>m>>k;
	prep();
	long long ans=1;
	for(int i=1;i<=k;++i){
		ans+=MUL(poww((k/i)*2+1,m)-1,mu[i]);
		ans%=mod;
		ans+=mod;
		ans%=mod;
	}
	cout<<ans;
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 5380kb

input:

2 1

output:

9

result:

ok single line: '9'

Test #2:

score: 0
Accepted
time: 2ms
memory: 5288kb

input:

2 2

output:

17

result:

ok single line: '17'

Test #3:

score: -100
Wrong Answer
time: 3ms
memory: 5428kb

input:

10000 10000

output:

618471672

result:

wrong answer 1st lines differ - expected: '689223145', found: '618471672'