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 fgjlwj at 2006-03-17 17:53:23 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),b,c,min=10000;//这里改为int a=(pow(N,1.0/3)+0.000001),b,c,min=10000;就可以了.
		for(;a>0;a--)
			if(N%a==0)
			{
				int tmp=N;
				tmp/=a;
				for(b=sqrt(tmp);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