QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#114069#6566. Power of DivisorsUFRJ#TL 1ms3816kbC++20907b2023-06-20 20:48:472023-06-20 20:48: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-06-20 20:48:48]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3816kb
  • [2023-06-20 20:48:47]
  • 提交

answer

#include "bits/stdc++.h"

using lint = int64_t;

using namespace std;

map<lint,lint> memo;

int countDiv(lint x) {
    set<lint> st;
    for(int i = 1; i <= x; i++) {
        if(x % i == 0) {
            st.insert(i);
            st.insert(x/i);
        }
    }
    return st.size();
}

lint f(lint x) {
    int cnt = countDiv(x);
    return pow(x, cnt);
}

void pre() {
    for(int i = 1; i < 100; i++) {
        int cnt = countDiv(i);
        long double ans = pow(i, cnt);
        if(ans < 1e18) {
            memo[lint(ans)] = i;
        }
    }
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  pre();
  lint n;
  cin >> n;
  for(int i = 2; i <= 70; i++) {
    lint raiz = round(pow(n, 1.0/i));
    // cout << raiz << endl;
    if(f(raiz) == n) {
        cout << raiz << endl;
        return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

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

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

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

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

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

input:

1

output:

1

result:

ok single line: '1'

Test #5:

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

input:

10

output:

-1

result:

ok single line: '-1'

Test #6:

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

input:

100

output:

-1

result:

ok single line: '-1'

Test #7:

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

input:

10000

output:

10

result:

ok single line: '10'

Test #8:

score: -100
Time Limit Exceeded

input:

1000000000000000000

output:


result: