QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#413009 | #6566. Power of Divisors | Lspeed# | WA | 68ms | 19952kb | C++14 | 3.0kb | 2024-05-16 23:41:41 | 2024-05-16 23:41:43 |
Judging History
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) {
ll temp = inf;
FOR (j, 0, numpow[i]) temp /= (ll)i;
if (temp == 0) continue;
if ((ll)k == (ll)pow((double)i, (double)(numpow[i]))) {
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: 22ms
memory: 19900kb
input:
15625
output:
25
result:
ok single line: '25'
Test #2:
score: 0
Accepted
time: 22ms
memory: 19952kb
input:
64000000
output:
20
result:
ok single line: '20'
Test #3:
score: 0
Accepted
time: 68ms
memory: 19892kb
input:
65536
output:
-1
result:
ok single line: '-1'
Test #4:
score: 0
Accepted
time: 4ms
memory: 18628kb
input:
1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 65ms
memory: 19880kb
input:
10
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 64ms
memory: 19904kb
input:
100
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 23ms
memory: 19804kb
input:
10000
output:
10
result:
ok single line: '10'
Test #8:
score: 0
Accepted
time: 26ms
memory: 19820kb
input:
1000000000000000000
output:
100
result:
ok single line: '100'
Test #9:
score: 0
Accepted
time: 31ms
memory: 19928kb
input:
10372926089038969
output:
218089
result:
ok single line: '218089'
Test #10:
score: 0
Accepted
time: 19ms
memory: 19820kb
input:
10642944803293201
output:
10157
result:
ok single line: '10157'
Test #11:
score: -100
Wrong Answer
time: 68ms
memory: 19840kb
input:
10646534823110209
output:
-1
result:
wrong answer 1st lines differ - expected: '103182047', found: '-1'