QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#413562#5715. 幂次x-camp95 270ms51412kbC++17985b2024-05-17 18:44:082024-05-17 18:44:08

Judging History

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

  • [2024-05-17 18:44:08]
  • 评测
  • 测评结果:95
  • 用时:270ms
  • 内存:51412kb
  • [2024-05-17 18:44:08]
  • 提交

answer



#include <iostream>
#include <vector>
#include <cmath>
#include <set>
using namespace std;


int main(int argc, const char * argv[]) {
    long long n;
    int k;
    cin >> n >> k;
    long long ans = 0;
    if (k == 1) ans = n ;
    else {
        set<long long> mp;
        if (k == 2) {
            long long x = sqrt(n);
            ans += x-1;
        }
       
        for (int i=max(k,3); i< 60; i++) {
            if (k == 2 && i %2 ==0) continue;
            for (int b=2; b< 1000000; b++) {
                int x = sqrt(b+1);
                if (x*x == b) continue;
                if (i <= log(n+1)/log(b)) {
                    long long y = pow(b,i) + 0.1;
                    if (y <= n) {
                        mp.insert(y);
                    }
                } else {
                    break;
                }
            }
        }
        ans += mp.size();
        ans ++;
    }
    cout << ans;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

92 1

output:

92

result:

ok 1 number(s): "92"

Test #2:

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

input:

96 2

output:

12

result:

ok 1 number(s): "12"

Test #3:

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

input:

9383 3

output:

37

result:

ok 1 number(s): "37"

Test #4:

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

input:

9830 2

output:

124

result:

ok 1 number(s): "124"

Test #5:

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

input:

927700 3

output:

149

result:

ok 1 number(s): "149"

Test #6:

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

input:

972504 2

output:

1097

result:

ok 1 number(s): "1097"

Test #7:

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

input:

94345650 3

output:

605

result:

ok 1 number(s): "605"

Test #8:

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

input:

98811802 2

output:

10429

result:

ok 1 number(s): "10429"

Test #9:

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

input:

9328450690 3

output:

2541

result:

ok 1 number(s): "2541"

Test #10:

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

input:

9775065820 2

output:

101083

result:

ok 1 number(s): "101083"

Test #11:

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

input:

948459050000 3

output:

11116

result:

ok 1 number(s): "11116"

Test #12:

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

input:

993120563000 2

output:

1006727

result:

ok 1 number(s): "1006727"

Test #13:

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

input:

93781484300000 3

output:

49275

result:

ok 1 number(s): "49275"

Test #14:

score: 5
Accepted
time: 8ms
memory: 6016kb

input:

98250912400000 2

output:

9958807

result:

ok 1 number(s): "9958807"

Test #15:

score: 5
Accepted
time: 50ms
memory: 14220kb

input:

9272034040000000 3

output:

221661

result:

ok 1 number(s): "221661"

Test #16:

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

input:

9981231040000000 2

output:

100122721

result:

ok 1 number(s): "100122721"

Test #17:

score: 5
Accepted
time: 259ms
memory: 51412kb

input:

942817384000000000 3

output:

1016053

result:

ok 1 number(s): "1016053"

Test #18:

score: 5
Accepted
time: 242ms
memory: 50612kb

input:

987478897000000000 2

output:

994718860

result:

ok 1 number(s): "994718860"

Test #19:

score: 5
Accepted
time: 250ms
memory: 49780kb

input:

932205945000000000 2

output:

966488284

result:

ok 1 number(s): "966488284"

Test #20:

score: 0
Wrong Answer
time: 270ms
memory: 50932kb

input:

992520149596833024 2

output:

997253883

result:

wrong answer 1st numbers differ - expected: '997253882', found: '997253883'