QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#124647#6566. Power of DivisorsSommohito#WA 944ms3432kbC++201.6kb2023-07-15 11:50:452023-07-15 11:50:48

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-15 11:50:48]
  • 评测
  • 测评结果:WA
  • 用时:944ms
  • 内存:3432kb
  • [2023-07-15 11:50:45]
  • 提交

answer

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#ifdef APURBA
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define ALL(x) x.begin(),x.end()
ll power(ll a, ll b)
{
    ll ans =1;
    while(b>0)
    {
        if(b&1ll)
        {
            ans = (ans*a);
        }
        a= (a*a);
        b>>=1ll;
    }
    return ans;
}
bool check(ll x , ll y)
{
    ll cnt = 0;
    for(ll i=1;i*i<=x;i++)
    {
        if(x%i==0)
        {
            cnt++;
            if(i!= (x/i))
                cnt++;
        }
    }
    return cnt == y;
}

ll fun(ll q , ll x)
{
    if(q==2)
    {
        ld lol = sqrtl((ld)x);
        for(ll p = max((ll)lol-2,1ll);p<=(ll)lol+2;p++)
        {
            if(p*p == x)
                return p;
        }
        return -1;
    }

    for(ll i=1;i<=x;i++)
    {
        ll val = power(i,q);
        if(val > x)
            return -1;
        if(val==x)
            return i;
    }
}
int32_t main()
{
#ifndef APURBA
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    ll x;
    cin>>x;
    for(ll q=2;q<=5000000;q++)
    {
        ll p = fun(q,x);
        if(p==-1)
            continue;
        if(check(p,q))
        {
            cout<<p<<"\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: 1ms
memory: 3400kb

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

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

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

score: 0
Accepted
time: 944ms
memory: 3392kb

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

score: -100
Wrong Answer
time: 269ms
memory: 3432kb

input:

1

output:

-1

result:

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