QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#234532 | #3161. Another Coin Weighing Puzzle | PhantomThreshold# | WA | 6ms | 13872kb | C++20 | 897b | 2023-11-01 18:52:44 | 2023-11-01 18:52:44 |
Judging History
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'