QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#74441 | #3161. Another Coin Weighing Puzzle | 541forever | WA | 3ms | 5428kb | C++14 | 856b | 2023-02-01 19:29:21 | 2023-02-01 19:29:24 |
Judging History
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'