QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#642275#6566. Power of Divisorsenze114514TL 0ms3960kbC++201.4kb2024-10-15 12:32:282024-10-15 12:32:28

Judging History

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

  • [2024-10-15 12:32:28]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3960kb
  • [2024-10-15 12:32:28]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define pb push_back

const ld pi = 3.14159265358979323846;
// const int mod = 998244353;
const ll INF = 1e18;

template<typename T>
T chmax(T a, T b) {
    return a > b ? a : b;
}

template<typename T>
T chmin(T a, T b) {
    return a > b ? b : a;
}

const int N = (int)2e5 + 1, M = N * 2;

ll qpow(ll a, ll b){
    ll res = 1;    
    
    while(b > 0){
        if(b % 2 == 1){
            res = (res * a); 
        }
        a = (a * a); 
        b /= 2;  
    }
    return res;
}

void solve(){
    ll x;
    cin >> x;

    auto f = [&](ll t) -> ll{      
        ll qwq = 0;  
        for(ll i = 1; i * i <= t; i++){
            if(t % i == 0){
                qwq++;
                if(t / i != i){
                    qwq++;
                }
            }
        }
        return qwq;
    };

    for(int i = 1; i <= 64; i++){
        ll t = (ll)pow(x, 1.0 / i);
        if(pow(t + 1, i) == x && f(t + 1) == i){
            cout << t + 1 << endl;
            return;
        }
        if(pow(t, i) == x && f(t) == i){
            cout << t << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
//    cin >> t;

    while(t--){
        solve();
    }

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3860kb

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

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

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

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

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

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

input:

1

output:

1

result:

ok single line: '1'

Test #5:

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

input:

10

output:

-1

result:

ok single line: '-1'

Test #6:

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

input:

100

output:

-1

result:

ok single line: '-1'

Test #7:

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

input:

10000

output:

10

result:

ok single line: '10'

Test #8:

score: -100
Time Limit Exceeded

input:

1000000000000000000

output:


result: