QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#413001#6566. Power of DivisorsLspeed#WA 1ms3848kbC++143.2kb2024-05-16 23:24:132024-05-16 23:24:13

Judging History

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

  • [2024-05-16 23:24:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3848kb
  • [2024-05-16 23:24:13]
  • 提交

answer

#include <iostream>     // Input/output stream objects
#include <fstream>      // File stream objects
#include <sstream>      // String stream objects
#include <iomanip>      // Input/output manipulators
#include <string>       // String class and functions
#include <vector>       // Dynamic array
#include <list>         // Doubly linked list
#include <set>          // Set container
#include <map>          // Map container
#include <queue>        // Queue container
#include <stack>        // Stack container
#include <algorithm>    // Algorithms on sequences (e.g., sort, find)
#include <cmath>        // Mathematical functions
#include <climits>      // LLONG_MAX, LLONG_MIN
#include <ctime>        // Date and time functions
#include <cstdlib>      // General purpose functions (e.g., memory management)
#include <cstring>      // C-style string functions
#include <cctype>       // Character classification functions
#include <cassert>      // Assert function for debugging
#include <exception>    // Standard exceptions
#include <functional>   // Function objects
#include <iterator>     // Iterator classes
#include <limits>       // Numeric limits
#include <locale>       // Localization and internationalization
#include <numeric>      // Numeric operations (e.g., accumulate)
#include <random>       // Random number generators
#include <stdexcept>    // Standard exception classes
#include <typeinfo>     // Runtime type information
#include <utility>      // Utility components (e.g., std::pair)
#include <bitset>

using namespace std;

#define FOR(i, a, b) for(int i = a; i < (b); i++)
#define FORE(i, a, b) for(int i = a; i <= (b); i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define x first 
#define y second
#define mp make_pair
#define PI 3.141592653
#define compress(coord) sort(all(coord)), coord.resize(unique(all(coord)) - coord.begin())
const double eps = 1e-9; // x < eps (x <= 0) x < -eps (x < 0)

const int N = 1e2;
vector<ll> numpow(N, 1), check(N), prime;
double k, inf = 1e18;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    cin >> k;
    if (k == 1) {
        cout << 1 << endl;
        return 0;
    }

    FOR(i, 2, N) if (!check[i]) {
        prime.push_back(i);
        for (int j = i; j < N; j += i) {
            check[j] = true;
            int temp = j, cnt = 0;
            while (temp % i == 0) {
                cnt++;
                temp /= i;
            }
            numpow[j] *= (ll)(cnt + 1);
        }
    }

    FOR (i, 2, N) {
        // cout << i << ": " << numpow[i] << " " << pow(inf, 1.0/numpow[i]) << endl;
        if (pow(inf, 1.0 / (double)numpow[i]) >= (double)i) {
            // cout << "HELLO " << i << " ";
            // cout << pow((double)i, (double)numpow[i]);
            if (k == pow((double)i, (double)(numpow[i]))) {
                cout << i << endl;
                return 0;
            }
        }
    }

    for (ll pp: prime) if ((ll)k % pp == 0) {
        cout << -1 << endl;
        return 0;
    }

    ll sq = (ll)sqrt(k);

    if (sq * sq == (ll)k) {
        cout << sq << 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: 3776kb

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

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

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

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

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

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

input:

1

output:

1

result:

ok single line: '1'

Test #5:

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

input:

10

output:

-1

result:

ok single line: '-1'

Test #6:

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

input:

100

output:

-1

result:

ok single line: '-1'

Test #7:

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

input:

10000

output:

10

result:

ok single line: '10'

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 3848kb

input:

1000000000000000000

output:

-1

result:

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