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

why WA? 纯暴力

Posted by direfire at 2006-10-19 00:33:31 on Problem 2363
#include <iostream> 
#include <sstream> 
#include <string> 
#include <vector> 
#include <set> 
#include <map> 
#include <algorithm> 
#include <cstdio> 
#include <cstdlib> 
#include <cmath>
#include <string.h>
using namespace std; 

#define REP(i, n) for(int i = 0; i<(n); i++) 
#define abs(a) ((a) >= 0 ? (a) : -(a)) 
#define inf 999999999 
typedef vector<int> VI; 
typedef vector<string> VS; 
typedef long long i64; 
typedef unsigned long long u64;


int n;
void go()
{
	int res = inf;
	for (int i = 1; i < n/2+1 ; i++)
	{
		if (n % i == 0) {
			for (int j = 1; j < n/i; j++)
			{
				if (n%(i*j) == 0) {
					int k = n/(i*j);
					int t = 2*i*j + 2*i*k +2*j*k;	
					if (t < res) res = t;
				}	
			}
		}	
	}	
	printf("%d\n", res);
	
}
int main()
{
	int C;
	cin>>C;
	for (int i = 0; i < C; i++)
	{
		cin>>n;
		if (n == 0) {printf("0\n"); continue;} 
		go();	
	}	
}

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