Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:都已经是暴力了怎么还WA。。。

Posted by gemenhao at 2006-04-02 11:20:37 on Problem 2363
In Reply To:都已经是暴力了怎么还WA。。。 Posted by:x1e398u at 2005-11-28 14:05:52
> #include <stdio.h>
> #include <math.h>
> 
> int main()
> {
> 	int T;
> 	scanf("%d",&T);
> 	for(;T>0;T--)
> 	{
> 		int N;
> 		scanf("%d",&N);
> 		int tmp=N;
> 		if(N==0)
> 		{
> 			printf("0\n");
> 			continue;
> 		}
> 		int a=pow(N,1.0/3)+1,b,c,min=10000;
                        //a 多加1就没事 ,还有下面的b也是
> 		for(;a>0;a--)
> 			if(N%a==0)
> 			{
> 				int tmp=N;
> 				tmp/=a;
> 				for(b = sqrt(tmp)+1;b>0;b--)
> 					if(tmp%b==0)
> 					{
> 						c=tmp/b;
> 						if(min>((a*b+b*c+c*a)<<1)) min=(a*b+b*c+c*a)<<1;
//这里可以直接跳出外面循环!!!!
> 					}
> 			}
> 		printf("%d\n",min);
> 	}
> 	return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator