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

这道题,用很暴力的方法都能0ms的。

Posted by cfanfrank at 2009-02-10 14:02:59 on Problem 2363
#include <stdio.h>


int main()
{
	int i, j, min, a, b, c;
	
	scanf("%d", &j);
	while (j--) {
		scanf("%d", &i);
		
		min = (int)0x7fffffff;
		for (a = 1; a <= 1000; a++) {
			if (a > i)
				break;
			for (b = 1; b <= 1000; b++) {
				if (a * b > i)
					break;
				for (c = 1; c <= 1000; c++) {
					if (a * b * c > i)
						break;

					if (a * b * c == i &&
						2 * (a * b + b * c + c * a) < min) 
						min = 2 * (a * b + b * c + c * a);
				}
			}
		}
		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