QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#706440 | #6566. Power of Divisors | ucup-team902# | WA | 26ms | 7568kb | C++17 | 1.1kb | 2024-11-03 11:21:35 | 2024-11-03 11:21:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define fi first
#define se second
#define bg begin
#define gc getchar
inline int read(){
char ch=gc();
int res=0;bool f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}
cs int N=1000005;
int d[N];
int main(){
#ifdef Stargazer
freopen("1.in","r",stdin);
#endif
ll x;cin>>x;
for(int i=1;i<N;i++)
for(int j=i;j<N;j+=i)d[j]++;
if(x==1){cout<<1<<'\n';return 0;}
for(int n=2;n<=1e6;n++){
ll s=1;int ok=0;
for(int j=1;j<=d[n];j++){
if(s>x/n)break;
s=s*n;
if(s==x&&j==d[n]){ok=1;break;}
}
if(ok){
cout<<n<<'\n';return 0;
}
}
ll t=sqrt(x);
if(t*t==x){
for(int i=2;1ll*i*i<=t;i++){
if(t%i==0){cout<<-1<<'\n';return 0;}
}
cout<<t<<'\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 23ms
memory: 7512kb
input:
15625
output:
25
result:
ok single line: '25'
Test #2:
score: 0
Accepted
time: 19ms
memory: 7492kb
input:
64000000
output:
20
result:
ok single line: '20'
Test #3:
score: 0
Accepted
time: 26ms
memory: 7568kb
input:
65536
output:
-1
result:
ok single line: '-1'
Test #4:
score: 0
Accepted
time: 23ms
memory: 7460kb
input:
1
output:
1
result:
ok single line: '1'
Test #5:
score: -100
Wrong Answer
time: 22ms
memory: 7432kb
input:
10
output:
result:
wrong answer 1st lines differ - expected: '-1', found: ''