QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#207990#6568. Space AlignmentThallium54#WA 10ms3644kbC++201.3kb2023-10-09 02:29:412023-10-09 02:29:42

Judging History

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

  • [2023-10-09 02:29:42]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:3644kb
  • [2023-10-09 02:29:41]
  • 提交

answer

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x;
    cin >> x;
    auto is_prime = [&](ll x) {
        for (int f = 2; f * f <= x; f++) {
            if (x % f == 0) return false;
        }
        return true;
    };

    ll sq = sqrt(x) + 5;
    while (sq * sq > x) sq--;
    if (sq * sq == x && is_prime(sq)) {
        cout << sq << endl;
        return 0;
    }

    const int N = 31623;
    for (int i = 1; i <= N; i++) {
        if (is_prime(i) && i <= 1000) {
            ll pp = i * i;
            if (pp * pp * pp == x) {
                cout << pp << endl;
                return 0;
            }
        }
        int cnt = 0;
        for (int f = 1; f * f <= i; f++) {
            if (i % f == 0) {
                cnt++;
                if (i / f != f) {
                    cnt++;
                }
            }
        }

        __int128 pw = 1;
        for (int j = 0; j < cnt; j++) {
            pw *= i;
            if (pw > 1e18) {
                break;
            }
        }

        if (pw == x) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 10ms
memory: 3644kb

input:

10
{
ss{
sts{
tt}
t}
t{
ss}
}
{
}

output:

-1

result:

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