QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#238634#6566. Power of DivisorsFyind#WA 1ms3824kbC++201.2kb2023-11-04 17:10:092023-11-04 17:10:09

Judging History

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

  • [2023-11-04 17:10:09]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3824kb
  • [2023-11-04 17:10:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define _ <<" "<<
#define sz(x) ((int) (x).size())
typedef pair<int, int> pii;
typedef long long ll;
const int maxn = 3e5 + 5;
typedef long long ll;
#define debug(x) cout<<#x<<':'<<x<<endl;
double root(ll n,ll x){
    double l=1,r=sqrt(n)+1;

    while(l+1e-3<r){
        double mid=(l+r)/2;
        //debug(mid);
        if(pow(mid,x)<=n) l=mid;
        else r=mid;
    }

    long long w= round(l);
    //debug(w);
    if(pow(w,x)==n){
        return w;
    }
    else {
        return -1;
    }

}

ll f(ll n){
    ll ans=1;ll y=n;
    for(int i=2;i<=sqrt(y+1e-8);i++){
        int t=1;
        while(n%i==0){
            n/=i;t++;
        }
        ans*=t;
    }
    if(n!=1) ans*=2;
    return ans;
}
void solve(){
   ll n;
   cin>>n;
   //debug(n);

   for(int k=2;k<200;k++){
        ll w=root(n,k);
        
        if(w==-1){
            continue;
        }
        // debug(w);
        // debug(k);
        // debug(f(w));
        if(f(w)==k){
            cout<<w<<endl;
            return ;
        }
        
   }
   cout<<-1<<endl;
}

int main(){
    int T;
    T=1;
    while(T--){
        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3596kb

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

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

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 3824kb

input:

1

output:

-1

result:

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