社区讨论

40pts求助

P4446[AHOI2018初中组] 根式化简参与者 1已保存回复 0

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
0 条
当前快照
1 份
快照标识符
@lo3egl99
此快照首次捕获于
2023/10/24 05:18
2 年前
此快照最后确认于
2023/10/24 05:18
2 年前
查看原帖
后6个点会WA
代码:
CPP
#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;
}

回复

0 条回复,欢迎继续交流。

正在加载回复...