QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#412536#6566. Power of Divisorsgrass8cow#WA 38ms7844kbC++17692b2024-05-16 15:52:582024-05-16 15:52:59

Judging History

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

  • [2024-05-16 15:52:59]
  • 评测
  • 测评结果:WA
  • 用时:38ms
  • 内存:7844kb
  • [2024-05-16 15:52:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll X;
const int n=1e6;
const ll I=1e18;
int d[1010000];
ll mu(ll x,ll y){if(x<=I/y)return x*y;return I+1;}
ll qpow(ll a,ll b){
    ll c=1;
    for(;b;b>>=1){
        if(b&1)c=mu(a,c);
        a=mu(a,a);
    }
    return c;
}
bool pri(ll x){
    for(ll i=2;i*i<=x;i++)if(!(x%i))return 0;return 1;
}
int main(){
    scanf("%lld",&X);
    for(int i=1;i<=n;i++)for(int j=1;i*j<=n;j++)d[i*j]++;
    for(int i=1;i<=n;i++)if(qpow(i,d[i])==X){printf("%d\n",i);return 0;}
    ll O=(ll)sqrt(X);
    while(O*O<X)O++;while(O*O>X)O--;
    if(pri(O)){printf("%lld\n",O);return 0;}
    puts("-1");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 22ms
memory: 7844kb

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

score: 0
Accepted
time: 19ms
memory: 7780kb

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

score: 0
Accepted
time: 37ms
memory: 7652kb

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

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

input:

1

output:

1

result:

ok single line: '1'

Test #5:

score: -100
Wrong Answer
time: 38ms
memory: 7840kb

input:

10

output:

3

result:

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