QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227570#6566. Power of DivisorsNerovix#WA 25ms7592kbC++201.1kb2023-10-27 18:50:082023-10-27 18:50:08

Judging History

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

  • [2023-10-27 18:50:08]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:7592kb
  • [2023-10-27 18:50:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int d[1000100];
ll qpow(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b & 1) {
            if(res > LLONG_MAX / a)
                return LLONG_MAX;
            res *= a;
        }
        if(a > LLONG_MAX / a)
            return LLONG_MAX;
        a *= a, b >>= 1;
    }
    return res;
}
bool isp(ll x) {
    for(ll i = 2; i * i <= x; i++)
        if(x % i == 0) return false;
    return true;
}
signed main() {
    ll x;
    cin >> x;
    for(int i = 1; i <= 1e6; i++)
        for(int j = i; j <= 1e6; j += i)
            d[j]++;
    for(int i = 1; i <= 1e6; i++) {
        ll t = x;
        while(t % i == 0 && d[i]) d[i]--, t /= i;
        if(t == 1 && d[i] == 0) {
            cout << i << '\n';
            return 0;
        }
    }
    // cout << 'f';
    ll p = sqrt(x);
    for(ll i = p - 10; i <= p + 10; i++) {
        if(i * i == x && isp(i)) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 22ms
memory: 7532kb

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

score: 0
Accepted
time: 17ms
memory: 7584kb

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

score: 0
Accepted
time: 20ms
memory: 7572kb

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

score: 0
Accepted
time: 18ms
memory: 7520kb

input:

1

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 22ms
memory: 7508kb

input:

10

output:

-1

result:

ok single line: '-1'

Test #6:

score: 0
Accepted
time: 25ms
memory: 7584kb

input:

100

output:

-1

result:

ok single line: '-1'

Test #7:

score: 0
Accepted
time: 15ms
memory: 7440kb

input:

10000

output:

10

result:

ok single line: '10'

Test #8:

score: 0
Accepted
time: 18ms
memory: 7504kb

input:

1000000000000000000

output:

100

result:

ok single line: '100'

Test #9:

score: 0
Accepted
time: 22ms
memory: 7592kb

input:

10372926089038969

output:

218089

result:

ok single line: '218089'

Test #10:

score: 0
Accepted
time: 22ms
memory: 7444kb

input:

10642944803293201

output:

10157

result:

ok single line: '10157'

Test #11:

score: 0
Accepted
time: 21ms
memory: 7528kb

input:

10646534823110209

output:

103182047

result:

ok single line: '103182047'

Test #12:

score: 0
Accepted
time: 19ms
memory: 7512kb

input:

1073741824

output:

32

result:

ok single line: '32'

Test #13:

score: 0
Accepted
time: 22ms
memory: 7444kb

input:

121

output:

11

result:

ok single line: '11'

Test #14:

score: 0
Accepted
time: 14ms
memory: 7504kb

input:

1296

output:

6

result:

ok single line: '6'

Test #15:

score: -100
Wrong Answer
time: 20ms
memory: 7516kb

input:

16

output:

-4

result:

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