QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#92172#5715. 幂次myee100 ✓60ms12832kbC++112.7kb2023-03-30 12:42:332023-03-30 12:42:34

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-30 12:42:34]
  • 评测
  • 测评结果:100
  • 用时:60ms
  • 内存:12832kb
  • [2023-03-30 12:42:33]
  • 提交

answer

// 那就是希望。
// 即便需要取模,也是光明。

#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
typedef long long llt;
typedef unsigned uint;typedef unsigned long long ullt;
typedef bool bol;typedef char chr;typedef void voi;
typedef double dbl;
template<typename T>bol _max(T&a,T b){return(a<b)?a=b,true:false;}
template<typename T>bol _min(T&a,T b){return(b<a)?a=b,true:false;}
template<typename T>T lowbit(T n){return n&-n;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T lcm(T a,T b){return(a!=0||b!=0)?a/gcd(a,b)*b:(T)0;}
template<typename T>T exgcd(T a,T b,T&x,T&y){if(b!=0){T ans=exgcd(b,a%b,y,x);y-=a/b*x;return ans;}else return y=0,x=1,a;}
template<typename T>T power(T base,T index,T mod)
{
    T ans=1%mod;
    while(index)
    {
        if(index&1)ans=ans*base%mod;
        base=base*base%mod,index>>=1;
    }
    return ans;
}
const ullt Lim[]={0,1000000000000000000,1000000000,1000000,50000,
                    5000,1000,500,200,100,63,43,31,24,19,15,13,11,
                    10,8,7,7,6,6,5,5,4,4,4,4,3,3,3,3,3,3,3,3,
                    2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};
ullt SQRT(ullt v){
    ullt ans=sqrt(v);
    while(ans*ans<v)ans++;
    while(ans*ans>v)ans--;
    return ans;
}
ullt Pow(ullt base,ullt index){
    ullt ans=1;
    while(index)
    {
        if(index&1)ans*=base;
        base*=base,index>>=1;
    }
    return ans;
}
int main()
{
#ifdef MYEE
    freopen("QAQ.in","r",stdin);
    freopen("QAQ.out","w",stdout);
#else
#endif
    ullt n,ans=1;uint k;scanf("%llu%u",&n,&k);
    std::vector<ullt>V;
    for(uint i=k;i<60&&(n>>i);i++){
        if(i==1){ans=n;break;}
        if(i==2){ans=SQRT(n);continue;}
        bol ok=1;
        for(uint t=k;t<i;t++)if(!(i%t))ok=0;
        if(!ok)continue;
        for(uint j=2;j<=Lim[i];j++){
            ullt v=Pow(j,i);
            if(v>n)continue;
            // bol ok=1;
            // for(uint t=k;ok&&t<i&&t<=19;t++){
            //     ullt g;
            //     if(t==2)g=SQRT(v);
            //     else{
            //         ullt l=8,r=Lim[t];
            //         while(l<r){
            //             ullt mid=(l+r+1)>>1;
            //             if(Pow(mid,t)<=v)l=mid;else r=mid-1;
            //         }
            //         g=l;
            //     }
            //     ok=Pow(g,t)!=v;
            // }
            // ans+=ok;
            if(k>2||Pow(SQRT(v),2)!=v)
                V.push_back(v);
        }
    }
    std::sort(V.begin(),V.end());
    V.erase(std::unique(V.begin(),V.end()),V.end());
    ans+=V.size();
    printf("%llu\n",ans);
    return 0;
}

// 那就是希望。
// 即便需要取模,也是光明。

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 5
Accepted
time: 2ms
memory: 3040kb

input:

92 1

output:

92

result:

ok 1 number(s): "92"

Test #2:

score: 5
Accepted
time: 2ms
memory: 3204kb

input:

96 2

output:

12

result:

ok 1 number(s): "12"

Test #3:

score: 5
Accepted
time: 4ms
memory: 3068kb

input:

9383 3

output:

37

result:

ok 1 number(s): "37"

Test #4:

score: 5
Accepted
time: 4ms
memory: 3208kb

input:

9830 2

output:

124

result:

ok 1 number(s): "124"

Test #5:

score: 5
Accepted
time: 4ms
memory: 3088kb

input:

927700 3

output:

149

result:

ok 1 number(s): "149"

Test #6:

score: 5
Accepted
time: 2ms
memory: 3132kb

input:

972504 2

output:

1097

result:

ok 1 number(s): "1097"

Test #7:

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

input:

94345650 3

output:

605

result:

ok 1 number(s): "605"

Test #8:

score: 5
Accepted
time: 4ms
memory: 3112kb

input:

98811802 2

output:

10429

result:

ok 1 number(s): "10429"

Test #9:

score: 5
Accepted
time: 3ms
memory: 3252kb

input:

9328450690 3

output:

2541

result:

ok 1 number(s): "2541"

Test #10:

score: 5
Accepted
time: 5ms
memory: 3180kb

input:

9775065820 2

output:

101083

result:

ok 1 number(s): "101083"

Test #11:

score: 5
Accepted
time: 2ms
memory: 3276kb

input:

948459050000 3

output:

11116

result:

ok 1 number(s): "11116"

Test #12:

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

input:

993120563000 2

output:

1006727

result:

ok 1 number(s): "1006727"

Test #13:

score: 5
Accepted
time: 7ms
memory: 3264kb

input:

93781484300000 3

output:

49275

result:

ok 1 number(s): "49275"

Test #14:

score: 5
Accepted
time: 3ms
memory: 3256kb

input:

98250912400000 2

output:

9958807

result:

ok 1 number(s): "9958807"

Test #15:

score: 5
Accepted
time: 9ms
memory: 4656kb

input:

9272034040000000 3

output:

221661

result:

ok 1 number(s): "221661"

Test #16:

score: 5
Accepted
time: 12ms
memory: 4792kb

input:

9981231040000000 2

output:

100122721

result:

ok 1 number(s): "100122721"

Test #17:

score: 5
Accepted
time: 48ms
memory: 12832kb

input:

942817384000000000 3

output:

1016053

result:

ok 1 number(s): "1016053"

Test #18:

score: 5
Accepted
time: 59ms
memory: 12092kb

input:

987478897000000000 2

output:

994718860

result:

ok 1 number(s): "994718860"

Test #19:

score: 5
Accepted
time: 56ms
memory: 12184kb

input:

932205945000000000 2

output:

966488284

result:

ok 1 number(s): "966488284"

Test #20:

score: 5
Accepted
time: 60ms
memory: 12284kb

input:

992520149596833024 2

output:

997253882

result:

ok 1 number(s): "997253882"

Extra Test:

score: 0
Extra Test Passed