QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#388707#5715. 幂次Ecec243100 ✓0ms4056kbC++141.3kb2024-04-13 18:25:522024-04-13 18:25:52

Judging History

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

  • [2024-04-13 18:25:52]
  • 评测
  • 测评结果:100
  • 用时:0ms
  • 内存:4056kb
  • [2024-04-13 18:25:52]
  • 提交

answer

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

typedef long long ll;
typedef long double db;

inline int read(){
    int x=0,w=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}
    while(c<='9'&&c>='0'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return x*w;
}

int pr[70],mu[70];
bool vis[70];
inline void LinearSieve(){
    for(int i=2;i<60;++i){
        if(!vis[i]) pr[++pr[0]]=i,mu[i]=-1;
        for(int j=1;j<=pr[0]&&i*pr[j]<60;++j){
            vis[i*pr[j]]=1,mu[i*pr[j]]=-mu[i];
            if(i%pr[j]==0){
                mu[i*pr[j]]=0;
                break;
            }
        }
    }
}

ll n;
int k;
ll cnt[70],ans;

int main(){
    scanf("%lld%d",&n,&k);
    if(k==1) return printf("%lld\n",n),0;
    if(k>=60) return printf("1\n"),0;
    LinearSieve();
    for(int i=2;i<=60;++i){
        ll l=1,r=(i==2)?1e9:cnt[i-1];
        while(l<=r){
            ll mid=(l+r)>>1;
            if((ll)powl(mid,i-1)>n/mid) r=mid-1;
            else cnt[i]=mid,l=mid+1; 
        }
    }
    for(int i=2;i<=60;++i) --cnt[i];
    ans=1;
    for(int i=k;i<60;++i){
        for(int j=2;i*j<60;++j){
            cnt[i]+=1ll*mu[j]*cnt[i*j];
        }
        ans+=cnt[i];
    }
    printf("%lld\n",ans);
    return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

92 1

output:

92

result:

ok 1 number(s): "92"

Test #2:

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

input:

96 2

output:

12

result:

ok 1 number(s): "12"

Test #3:

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

input:

9383 3

output:

37

result:

ok 1 number(s): "37"

Test #4:

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

input:

9830 2

output:

124

result:

ok 1 number(s): "124"

Test #5:

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

input:

927700 3

output:

149

result:

ok 1 number(s): "149"

Test #6:

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

input:

972504 2

output:

1097

result:

ok 1 number(s): "1097"

Test #7:

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

input:

94345650 3

output:

605

result:

ok 1 number(s): "605"

Test #8:

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

input:

98811802 2

output:

10429

result:

ok 1 number(s): "10429"

Test #9:

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

input:

9328450690 3

output:

2541

result:

ok 1 number(s): "2541"

Test #10:

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

input:

9775065820 2

output:

101083

result:

ok 1 number(s): "101083"

Test #11:

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

input:

948459050000 3

output:

11116

result:

ok 1 number(s): "11116"

Test #12:

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

input:

993120563000 2

output:

1006727

result:

ok 1 number(s): "1006727"

Test #13:

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

input:

93781484300000 3

output:

49275

result:

ok 1 number(s): "49275"

Test #14:

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

input:

98250912400000 2

output:

9958807

result:

ok 1 number(s): "9958807"

Test #15:

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

input:

9272034040000000 3

output:

221661

result:

ok 1 number(s): "221661"

Test #16:

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

input:

9981231040000000 2

output:

100122721

result:

ok 1 number(s): "100122721"

Test #17:

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

input:

942817384000000000 3

output:

1016053

result:

ok 1 number(s): "1016053"

Test #18:

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

input:

987478897000000000 2

output:

994718860

result:

ok 1 number(s): "994718860"

Test #19:

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

input:

932205945000000000 2

output:

966488284

result:

ok 1 number(s): "966488284"

Test #20:

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

input:

992520149596833024 2

output:

997253882

result:

ok 1 number(s): "997253882"

Extra Test:

score: 0
Extra Test Passed