QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#413003#6566. Power of DivisorsLspeed#WA 40ms19900kbC++143.0kb2024-05-16 23:27:192024-05-16 23:27:19

Judging History

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

  • [2024-05-16 23:27:19]
  • 评测
  • 测评结果:WA
  • 用时:40ms
  • 内存:19900kb
  • [2024-05-16 23:27:19]
  • 提交

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 (i, 2, N) {
        if (pow(inf, 1.0 / (double)numpow[i]) >= (double)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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 19ms
memory: 19876kb

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

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

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

score: 0
Accepted
time: 36ms
memory: 19784kb

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

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

input:

1

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 40ms
memory: 19788kb

input:

10

output:

-1

result:

ok single line: '-1'

Test #6:

score: 0
Accepted
time: 40ms
memory: 19900kb

input:

100

output:

-1

result:

ok single line: '-1'

Test #7:

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

input:

10000

output:

10

result:

ok single line: '10'

Test #8:

score: -100
Wrong Answer
time: 40ms
memory: 19800kb

input:

1000000000000000000

output:

-1

result:

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