40pts求助
查看原帖
40pts求助
659471
Sky_city楼主2023/1/7 12:15

后6个点会WA
代码:

#include <bits/stdc++.h>
using namespace std;
int prime_list[10010],cnt=0;
bool prime[40010]; 
void Prime(){
	int n=31650;
	prime[1]=true;
	for(int i=2;i<=n;i++) 
	{
		if (!prime[i])
			prime_list[++cnt]=i;
		for(int j=1;j<=cnt&&i*prime_list[j]<=n;j++)
		{
			prime[i*prime_list[j]]=true;
			if (i%prime_list[j]==0)
				break;
		}
	}
}
int main(){
	Prime();
	int T;
	scanf("%d",&T);
	while(T--)
	{
		int ans=1;
		long long x;
		scanf("%lld",&x);
		for(int i=1;i<=cnt;i++)
		{
			if (prime_list[i]>x) break;
			int temp=0;
			while(x%prime_list[i]==0)
				temp++,x/=prime_list[i];
			ans=ans*pow(prime_list[i],temp/3);			
		}
		printf("%d\n",ans);
	}
	return 0;
}
2023/1/7 12:15
加载中...