user-0 提问: 求快速找最大无完全平方因子

回复:
user: user-0
content: 引用 11 楼 牧濑EL的回复:顺便问一下题目链接 学校的题目，要连内网

user: user-1
content: 顺便问一下题目链接

user: user-1
content: 分解质因数，然后扫一遍把不重复的累乘起来即可。 比如分解出来n=2*2*2*3*7*11*11 直接输出2*3*7*11 你写的也太麻烦了。

user: user-0
content: 引用 6 楼 牧濑EL 的回复:[quote=引用 5 楼 qq_45697381 的回复:] [quote=引用 4 楼 user-2的回复:]没有，把你说超时的发出来啊 #include<stdio.h>#include<string.h>#include<math.h>#define nuh 1005L#define nu 1005#define N 1000005long long num[nu]={1,1},number=0;                                             int prime[N],cnt=0;int fllag[N]={0};void Prime(){	for(int i=2;i<N;i++){		if(fllag[i]) continue;		prime[cnt++]=i;		for(int j=2;j*i<N;j++)			fllag[i*j]=1;	}}	int main(void){	long long input[20];	long long n;	int flagOne;	int flagTwo;	long long yinshu[10005];	int firstTry,secondTry;		int flag=0;	int fi,se;		Prime();		for(flagOne=0;scanf("%lld",&input[flagOne])!=EOF;flagOne++);		for(flagTwo=0;flagTwo<flagOne;flagTwo++)	{				n=input[flagTwo];		for(firstTry=1;firstTry<n/2+0.6;firstTry++)		{			if(n%firstTry==0)			{			yinshu[flag++]=firstTry;			}		}		yinshu[flag]=n;				for(secondTry=flag;secondTry>=0;secondTry--)		{			for(fi=se=0;yinshu[secondTry]%(prime[fi]*prime[fi])!=0&&prime[fi]*prime[fi]<=yinshu[secondTry];fi++)			{				if(yinshu[secondTry]%(prime[fi+1]*prime[fi+1])!=0&&prime[fi+1]*prime[fi+1]>=yinshu[secondTry])		[/quote] 会不会粘代码……[/quote] #include<stdio.h> #include<string.h> #include<math.h> #define nuh 1005 #define nu 1005 #define N 1000005 long long num[nu]={1,1},number=0;                                              int prime[N],cnt=0; int fllag[N]={0};    void Prime(){ 	for(int i=2;i<N;i++){ 		if(fllag[i]) continue; 		prime[cnt++]=i; 		for(int j=2;j*i<N;j++) 			fllag[i*j]=1; 	} }	   int main(void) {  	long long input[20]; 	long long n; 	int flagOne; 	int flagTwo; 	long long yinshu[10005]; 	int firstTry,secondTry;	 	int flag=0; 	int fi,se;  	Prime();  	for(flagOne=0;scanf("%lld",&input[flagOne])!=EOF;flagOne++);  	for(flagTwo=0;flagTwo<flagOne;flagTwo++) 	{  		n=input[flagTwo];  		for(firstTry=1;firstTry<n/2+0.6;firstTry++) 		{ 			if(n%firstTry==0) 			{ 			yinshu[flag++]=firstTry; 			} 		} 		yinshu[flag]=n;  		for(secondTry=flag;secondTry>=0;secondTry--) 		{ 			for(fi=se=0;yinshu[secondTry]%(prime[fi]*prime[fi])!=0&&prime[fi]*prime[fi]<=yinshu[secondTry];fi++) 			{ 				if(yinshu[secondTry]%(prime[fi+1]*prime[fi+1])!=0&&prime[fi+1]*prime[fi+1]>=yinshu[secondTry]) 				{ 				printf("%lld\n",yinshu[secondTry]); 				secondTry=0; 				break;	 				} 			} 		}   	//	printf("%lld\n",yinshu[secondTry]); 	}  	return 0; }

user: user-0
content: 引用 3 楼 qq_45697381 的回复:[quote=引用 2 楼 user-2的回复:]发出来发出来发出来！ 你也在写这题？？？？？？[/quote] #include<stdio.h> #include<string.h> #include<math.h> #define nuh 1005 #define nu 1005 #define N 1000005 long long num[nu]={1,1},number=0;                                              int prime[N],cnt=0; int fllag[N]={0};    void Prime(){ 	for(int i=2;i<N;i++){ 		if(fllag[i]) continue; 		prime[cnt++]=i; 		for(int j=2;j*i<N;j++) 			fllag[i*j]=1; 	} }	   int main(void) {  	long long input[20]; 	long long n; 	int flagOne; 	int flagTwo; 	long long yinshu[10005]; 	int firstTry,secondTry;	 	int flag=0; 	int fi,se;  	Prime();  	for(flagOne=0;scanf("%lld",&input[flagOne])!=EOF;flagOne++);  	for(flagTwo=0;flagTwo<flagOne;flagTwo++) 	{  		n=input[flagTwo];  		for(firstTry=1;firstTry<n/2+0.6;firstTry++) 		{ 			if(n%firstTry==0) 			{ 			yinshu[flag++]=firstTry; 			} 		} 		yinshu[flag]=n;  		for(secondTry=flag;secondTry>=0;secondTry--) 		{ 			for(fi=se=0;yinshu[secondTry]%(prime[fi]*prime[fi])!=0&&prime[fi]*prime[fi]<=yinshu[secondTry];fi++) 			{ 				if(yinshu[secondTry]%(prime[fi+1]*prime[fi+1])!=0&&prime[fi+1]*prime[fi+1]>=yinshu[secondTry]) 				{ 				printf("%lld\n",yinshu[secondTry]); 				secondTry=0; 				break;	 				} 			} 		}   	//	printf("%lld\n",yinshu[secondTry]); 	}  	return 0; }

user: user-0
content: 引用 6 楼 牧濑EL的回复:[quote=引用 5 楼 qq_45697381 的回复:] [quote=引用 4 楼 user-2的回复:]没有，把你说超时的发出来啊 #include<stdio.h>#include<string.h>#include<math.h>#define nuh 1005L#define nu 1005#define N 1000005long long num[nu]={1,1},number=0;                                             int prime[N],cnt=0;int fllag[N]={0};void Prime(){	for(int i=2;i<N;i++){		if(fllag[i]) continue;		prime[cnt++]=i;		for(int j=2;j*i<N;j++)			fllag[i*j]=1;	}}	int main(void){	long long input[20];	long long n;	int flagOne;	int flagTwo;	long long yinshu[10005];	int firstTry,secondTry;		int flag=0;	int fi,se;		Prime();		for(flagOne=0;scanf("%lld",&input[flagOne])!=EOF;flagOne++);		for(flagTwo=0;flagTwo<flagOne;flagTwo++)	{				n=input[flagTwo];		for(firstTry=1;firstTry<n/2+0.6;firstTry++)		{			if(n%firstTry==0)			{			yinshu[flag++]=firstTry;			}		}		yinshu[flag]=n;				for(secondTry=flag;secondTry>=0;secondTry--)		{			for(fi=se=0;yinshu[secondTry]%(prime[fi]*prime[fi])!=0&&prime[fi]*prime[fi]<=yinshu[secondTry];fi++)			{				if(yinshu[secondTry]%(prime[fi+1]*prime[fi+1])!=0&&prime[fi+1]*prime[fi+1]>=yinshu[secondTry])		[/quote] 会不会粘代码……[/quote] 传到手机上粘的，我在传一次T^T

user: user-1
content: 引用 5 楼 qq_45697381 的回复:[quote=引用 4 楼 user-2的回复:]没有，把你说超时的发出来啊 #include<stdio.h>#include<string.h>#include<math.h>#define nuh 1005L#define nu 1005#define N 1000005long long num[nu]={1,1},number=0;                                             int prime[N],cnt=0;int fllag[N]={0};void Prime(){	for(int i=2;i<N;i++){		if(fllag[i]) continue;		prime[cnt++]=i;		for(int j=2;j*i<N;j++)			fllag[i*j]=1;	}}	int main(void){	long long input[20];	long long n;	int flagOne;	int flagTwo;	long long yinshu[10005];	int firstTry,secondTry;		int flag=0;	int fi,se;		Prime();		for(flagOne=0;scanf("%lld",&input[flagOne])!=EOF;flagOne++);		for(flagTwo=0;flagTwo<flagOne;flagTwo++)	{				n=input[flagTwo];		for(firstTry=1;firstTry<n/2+0.6;firstTry++)		{			if(n%firstTry==0)			{			yinshu[flag++]=firstTry;			}		}		yinshu[flag]=n;				for(secondTry=flag;secondTry>=0;secondTry--)		{			for(fi=se=0;yinshu[secondTry]%(prime[fi]*prime[fi])!=0&&prime[fi]*prime[fi]<=yinshu[secondTry];fi++)			{				if(yinshu[secondTry]%(prime[fi+1]*prime[fi+1])!=0&&prime[fi+1]*prime[fi+1]>=yinshu[secondTry])		[/quote] 会不会粘代码……

user: user-0
content: 引用 4 楼 user-2的回复:没有，把你说超时的发出来啊 #include<stdio.h>#include<string.h>#include<math.h>#define nuh 1005L#define nu 1005#define N 1000005long long num[nu]={1,1},number=0;                                             int prime[N],cnt=0;int fllag[N]={0};void Prime(){	for(int i=2;i<N;i++){		if(fllag[i]) continue;		prime[cnt++]=i;		for(int j=2;j*i<N;j++)			fllag[i*j]=1;	}}	int main(void){	long long input[20];	long long n;	int flagOne;	int flagTwo;	long long yinshu[10005];	int firstTry,secondTry;		int flag=0;	int fi,se;		Prime();		for(flagOne=0;scanf("%lld",&input[flagOne])!=EOF;flagOne++);		for(flagTwo=0;flagTwo<flagOne;flagTwo++)	{				n=input[flagTwo];		for(firstTry=1;firstTry<n/2+0.6;firstTry++)		{			if(n%firstTry==0)			{			yinshu[flag++]=firstTry;			}		}		yinshu[flag]=n;				for(secondTry=flag;secondTry>=0;secondTry--)		{			for(fi=se=0;yinshu[secondTry]%(prime[fi]*prime[fi])!=0&&prime[fi]*prime[fi]<=yinshu[secondTry];fi++)			{				if(yinshu[secondTry]%(prime[fi+1]*prime[fi+1])!=0&&prime[fi+1]*prime[fi+1]>=yinshu[secondTry])

user: user-2
content: 没有，把你说超时的发出来啊

user: user-0
content: 引用 2 楼 user-2的回复:发出来发出来发出来！ 你也在写这题？？？？？？

user: user-2
content: 发出来发出来发出来！

user: user-0
content: 引用 楼主 qq_45697381的回复:In Ruby's mind, there exists a sort of numbers, which are called awesome number. Ruby defines that, a positive integer x is called awesome if and only if there is no such positive integer a > 1 such that a^2 is divisor of x.Sapphire has a magical pocket, which contains all the divisors of n. As a nice present, Sapphire wants to give an awesome number to Ruby. Besides, she wants this number should as big as possible. Therefore, the current issue is what is the biggest awesome number in her pocket.  InputThere're multiple data sets. Each set contains a single line. Each line contains a number, which represents n. 1 <= n <= 1,000,000,000,000  OutputPrint the biggest awesome number in each line.  Sample Input  10 12  Sample Output  10  6  HintIn the 1st case, there exists 1, 2, 5 and 10 in the pocket. 10 is not divisible by any perfect square, so 10 is awesome. In the 2nd case, there exists 1, 2, 3, 4, 6 and 12 in the pocket. 12 is divisible by 4 (4 = 2 * 2). Hence, 12 is not awesome, where 6 is indeed awesome. 限时1000ms，写了好几种方法一直在超时