QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#244444#5715. 幂次LYT0122100 ✓201ms68488kbC++141.4kb2023-11-09 06:33:142023-11-09 06:33:15

Judging History

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

  • [2023-11-09 06:33:15]
  • 评测
  • 测评结果:100
  • 用时:201ms
  • 内存:68488kb
  • [2023-11-09 06:33:14]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
const int N=1e6+9,INF=1e9;
const double eps=1e-5;
typedef pair <int,int> PII;
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0' || c>'9') {if(c=='-') f=-1;c=getchar();}
    while(c>='0' && c<='9') {x=x*10+c-48,c=getchar();}
    return x*f;
}
inline ll readll()
{
    ll x=0,f=1;char c=getchar();
    while(c<'0' || c>'9') {if(c=='-') f=-1;c=getchar();}
    while(c>='0' && c<='9') {x=x*10+c-48,c=getchar();}
    return x*f;
}
int k;
ll n,ans,sum;
map <ll,bool> M;
int main()
{
    // #define FILEIO
    #ifdef FILEIO
        freopen("in.in","r",stdin);
        freopen("out.out","w",stdout);
    #endif
    n=readll(),k=read();
    if(k==1) cout<<n;
    else
    {
        for(ll i=2;i*i*i<=n;i++)
        {
            int cnt=2;
            ll x=i*i;
            while(x<=n/i)
            {
                x*=i,cnt++;
                if(cnt<k || M.count(x)) continue;
                ll tmp=sqrtl(x);
                if(tmp*tmp==x) sum++;
                ans++,M[x]=true;
            }
        }
        if(k>=3) cout<<ans+1;
        else cout<<(ll)sqrtl(n)+ans-sum;
    }
    cerr<<endl<<1e3*clock()/CLOCKS_PER_SEC<<"ms";
    return 0;
}

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

詳細信息

Test #1:

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

input:

92 1

output:

92

result:

ok 1 number(s): "92"

Test #2:

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

input:

96 2

output:

12

result:

ok 1 number(s): "12"

Test #3:

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

input:

9383 3

output:

37

result:

ok 1 number(s): "37"

Test #4:

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

input:

9830 2

output:

124

result:

ok 1 number(s): "124"

Test #5:

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

input:

927700 3

output:

149

result:

ok 1 number(s): "149"

Test #6:

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

input:

972504 2

output:

1097

result:

ok 1 number(s): "1097"

Test #7:

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

input:

94345650 3

output:

605

result:

ok 1 number(s): "605"

Test #8:

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

input:

98811802 2

output:

10429

result:

ok 1 number(s): "10429"

Test #9:

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

input:

9328450690 3

output:

2541

result:

ok 1 number(s): "2541"

Test #10:

score: 5
Accepted
time: 1ms
memory: 4080kb

input:

9775065820 2

output:

101083

result:

ok 1 number(s): "101083"

Test #11:

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

input:

948459050000 3

output:

11116

result:

ok 1 number(s): "11116"

Test #12:

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

input:

993120563000 2

output:

1006727

result:

ok 1 number(s): "1006727"

Test #13:

score: 5
Accepted
time: 6ms
memory: 6960kb

input:

93781484300000 3

output:

49275

result:

ok 1 number(s): "49275"

Test #14:

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

input:

98250912400000 2

output:

9958807

result:

ok 1 number(s): "9958807"

Test #15:

score: 5
Accepted
time: 35ms
memory: 17776kb

input:

9272034040000000 3

output:

221661

result:

ok 1 number(s): "221661"

Test #16:

score: 5
Accepted
time: 42ms
memory: 18116kb

input:

9981231040000000 2

output:

100122721

result:

ok 1 number(s): "100122721"

Test #17:

score: 5
Accepted
time: 199ms
memory: 67384kb

input:

942817384000000000 3

output:

1016053

result:

ok 1 number(s): "1016053"

Test #18:

score: 5
Accepted
time: 201ms
memory: 68420kb

input:

987478897000000000 2

output:

994718860

result:

ok 1 number(s): "994718860"

Test #19:

score: 5
Accepted
time: 184ms
memory: 67088kb

input:

932205945000000000 2

output:

966488284

result:

ok 1 number(s): "966488284"

Test #20:

score: 5
Accepted
time: 199ms
memory: 68488kb

input:

992520149596833024 2

output:

997253882

result:

ok 1 number(s): "997253882"

Extra Test:

score: 0
Extra Test Passed