QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#234532#3161. Another Coin Weighing PuzzlePhantomThreshold#WA 6ms13872kbC++20897b2023-11-01 18:52:442023-11-01 18:52:44

Judging History

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

  • [2023-11-01 18:52:44]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:13872kb
  • [2023-11-01 18:52:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod=998244353;
ll ksm(ll a,ll x){
	ll ret=1;
	for (;x;x>>=1,a=a*a%mod) if (x&1) ret=ret*a%mod;
	return ret;	
}
ll inv(ll a){return ksm(a,mod-2);}

const int maxn=1000000;
bool notp[maxn+50];
int pcnt=0;
ll p[(maxn>>2)+50];
ll mu[maxn+50];

void prepare(){
	notp[1]=1;
	mu[1]=1;
	for (int i=2;i<=maxn;i++){
		if (!notp[i]){
			p[++pcnt]=i;
			mu[i]=mod-1;
		}
		for (int j=1,x=1;j<=pcnt && (x=i*p[j])<=maxn;j++){
			notp[x]=1;
			if (i%p[j]){
				mu[x]=mod-mu[i];
			}
			else{
				mu[x]=0;
				break;	
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	prepare();
	ll m,k;
	cin >> m >> k;
	
	ll ans=0;
	for (ll i=1;i<=k;i++){
		ans=(ans+mu[i]*ksm(k/i,m))%mod;
	}
	ans=(ans+mod-1)*ksm(2,m)%mod;
	ans=(ans+ksm(3,m))%mod;
	cout << ans << "\n";
	return 0;	
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 13872kb

input:

2 1

output:

9

result:

ok single line: '9'

Test #2:

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

input:

2 2

output:

17

result:

ok single line: '17'

Test #3:

score: -100
Wrong Answer
time: 6ms
memory: 13412kb

input:

10000 10000

output:

803996825

result:

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