QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#413012#6566. Power of DivisorsLspeed#WA 29ms19936kbC++143.1kb2024-05-16 23:52:162024-05-16 23:52:18

Judging History

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

  • [2024-05-16 23:52:18]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:19936kb
  • [2024-05-16 23:52:16]
  • 提交

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 = 1e6 + 10;
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 (ll i = 2; i < N; i++) {
        ll curpow = 1;
        bool of = false;
        FOR (j, 0, numpow[i]) {
            if (inf / i >= curpow)  curpow *= i;
            else {
                of = true;
                break;
            }
        }

        if (!of && curpow == k) {
            cout << i << endl;
            return 0;
        }
    }

    ll sq = (ll)sqrt(k);

    if (sq * sq == (ll)k) {
        for (ll pp : prime) if (sq % pp == 0) {
            cout << -1 << endl;
            return 0;
        } 
        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: 24ms
memory: 19908kb

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

score: 0
Accepted
time: 29ms
memory: 19832kb

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

score: 0
Accepted
time: 23ms
memory: 19844kb

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

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

input:

1

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 28ms
memory: 19912kb

input:

10

output:

-1

result:

ok single line: '-1'

Test #6:

score: 0
Accepted
time: 27ms
memory: 19872kb

input:

100

output:

-1

result:

ok single line: '-1'

Test #7:

score: 0
Accepted
time: 23ms
memory: 19884kb

input:

10000

output:

10

result:

ok single line: '10'

Test #8:

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

input:

1000000000000000000

output:

100

result:

ok single line: '100'

Test #9:

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

input:

10372926089038969

output:

218089

result:

ok single line: '218089'

Test #10:

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

input:

10642944803293201

output:

10157

result:

ok single line: '10157'

Test #11:

score: -100
Wrong Answer
time: 23ms
memory: 19880kb

input:

10646534823110209

output:

-1

result:

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