QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#238699#6566. Power of DivisorsFyind#Compile Error//C++201.3kb2023-11-04 17:17:452023-11-04 17:17:45

Judging History

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

  • [2023-11-04 17:17:45]
  • 评测
  • [2023-11-04 17:17:45]
  • 提交

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;
ll ksm(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1){
            ans=ans*a;
        }
        a=a*a;
        n>>=1;
    }
    return ans;
}
double root(ll n,ll x){
    double l=1,r=sqrt(n)+1;

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

    long long w= round(l);
    if(ksm(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+1);i++){
        ll t=1;
        while(n%i==0){
            n/=i;t++;
        }
        ans*=t;
    }
    if(n!=1) ans*=2;
    return ans;
}
void solve(){
   ll n;
   cin>>n;
   if(x==1){
    cout<<1<<endl;
    return;
   }

   for(int k=2;k<200;k++){
        ll w=root(n,k);
        
        if(w==-1){
            continue;
        }

        if(f(w)==k){
            cout<<w<<endl;
            return ;
        }
        
   }
   cout<<-1<<endl;
}

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

Details

answer.code: In function ‘void solve()’:
answer.code:55:7: error: ‘x’ was not declared in this scope
   55 |    if(x==1){
      |       ^