QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#110860#6566. Power of DivisorsHe_Ren#WA 39ms7084kbC++17701b2023-06-04 13:25:442023-06-04 13:25:45

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-04 13:25:45]
  • 评测
  • 测评结果:WA
  • 用时:39ms
  • 内存:7084kb
  • [2023-06-04 13:25:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

bool isprime(ll x)
{
	if(x <= 1) return 0;
	for(ll i=2; i*i<=x; ++i)
		if(x % i == 0)
			return 0;
	return 1;
}

int main(void)
{
	ll x;
	scanf("%lld",&x);
	
	const int n = 1e6;
	vector<int> f(n + 1);
	for(int i=1; i<=n; ++i)
		for(int j=i; j<=n; j+=i)
			++f[j];
	
	for(int i=1; i<=n; ++i)
	{
		__int128 cur = 1;
		for(int j=1; j<=f[i] && cur<=x; ++j)
			cur *= i;
		if(cur == x)
		{
			printf("%d\n",i);
			return 0;
		}
	}
	
	ll y = sqrt(x) + 5;
	while(y * y > x) --y;
	if(isprime(y))
	{
		printf("%lld\n",y);
		return 0;
	}
	
	printf("-1\n");
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 24ms
memory: 7084kb

input:

15625

output:

25

result:

ok single line: '25'

Test #2:

score: 0
Accepted
time: 26ms
memory: 6984kb

input:

64000000

output:

20

result:

ok single line: '20'

Test #3:

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

input:

65536

output:

-1

result:

ok single line: '-1'

Test #4:

score: 0
Accepted
time: 39ms
memory: 7004kb

input:

1

output:

1

result:

ok single line: '1'

Test #5:

score: -100
Wrong Answer
time: 33ms
memory: 7016kb

input:

10

output:

3

result:

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