QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#594499 | #6566. Power of Divisors | llg | WA | 58ms | 7628kb | C++14 | 1.8kb | 2024-09-28 00:56:21 | 2024-09-28 00:56:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define mod 1000000007
const int N = 1e6 + 5;
int lp[N];
void sieve(int n)
{
lp[1] = 1;
for (int i = 2; i <= n; i++)
{
for (int j = i; j <= n; j += i)
{
if (lp[j] == 0)
{
lp[j] = i;
}
}
}
}
int number_of_divisors(int n)
{
int ans = 1;
while (n > 1)
{
int p = lp[n];
int cnt = 0;
while (n % p == 0)
{
n /= p;
cnt++;
}
ans *= (cnt + 1);
}
return ans;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("a.in", "r", stdin);
freopen("a.out", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
sieve(1e6 + 2);
ll x;
cin >> x;
ll cur = (ll)sqrt(x);
ll ans = 1e18;
if (cur * cur == x)
{
ans = min(ans, cur);
}
// cout << number_of_divisors(20) << endl;
for (int i = 1; i <= 1e6; i++)
{
int y = number_of_divisors(i);
ll power = 1;
if (y == 2)
{
continue;
}
else
{
for (int j = 0; j < y; j++)
{
if (power > 1e18 / i)
{
break;
}
power *= i;
}
}
if (power == x)
{
ans = min(ans, (ll)i);
}
}
cout << ans << endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 53ms
memory: 7564kb
input:
15625
output:
25
result:
ok single line: '25'
Test #2:
score: 0
Accepted
time: 53ms
memory: 7568kb
input:
64000000
output:
20
result:
ok single line: '20'
Test #3:
score: -100
Wrong Answer
time: 58ms
memory: 7628kb
input:
65536
output:
256
result:
wrong answer 1st lines differ - expected: '-1', found: '256'