QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#227568#6566. Power of DivisorsNerovix#WA 29ms7592kbC++201.0kb2023-10-27 18:46:402023-10-27 18:46:41

Judging History

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

  • [2023-10-27 18:46:41]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:7592kb
  • [2023-10-27 18:46:40]
  • 提交

answer

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

typedef long long ll;

int d[1000100];
ll qpow(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b & 1) {
            if(res > LLONG_MAX / a)
                return LLONG_MAX;
            res *= a;
        }
        if(a > LLONG_MAX / a)
            return LLONG_MAX;
        a *= a, b >>= 1;
    }
    return res;
}
bool isp(ll x) {
    for(ll i = 2; i * i <= x; i++)
        if(x % i == 0) return false;
    return true;
}
signed main() {
    ll x;
    cin >> x;
    for(int i = 1; i <= 1e6; i++)
        for(int j = i; j <= 1e6; j += i)
            d[j]++;
    for(int i = 1; i <= 1e6; i++) {
        // cout << i << ' ' << d[i] << '\n';
        if(qpow(i, d[i]) == x) {
            cout << i << '\n';
            return 0;
        }
    }
    // cout << 'f';
    ll p = sqrt(x);
    for(ll i = p - 10; i <= p + 10; i++) {
        if(i * i == x && isp(i)) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 19ms
memory: 7436kb

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

score: 0
Accepted
time: 22ms
memory: 7532kb

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

score: 0
Accepted
time: 29ms
memory: 7504kb

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

score: 0
Accepted
time: 18ms
memory: 7588kb

input:

1

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 26ms
memory: 7500kb

input:

10

output:

-1

result:

ok single line: '-1'

Test #6:

score: 0
Accepted
time: 25ms
memory: 7592kb

input:

100

output:

-1

result:

ok single line: '-1'

Test #7:

score: 0
Accepted
time: 23ms
memory: 7504kb

input:

10000

output:

10

result:

ok single line: '10'

Test #8:

score: -100
Wrong Answer
time: 28ms
memory: 7504kb

input:

1000000000000000000

output:

-1

result:

wrong answer 1st lines differ - expected: '100', found: '-1'