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

晕死!就是不过

Posted by 515197964 at 2010-08-26 18:53:04 on Problem 3536
#include<iostream>
using namespace std;
int n[1000];

int factor(int na)
{
	int num=0;
	for(int i=1;i<na+1;i++)
		if(na%i==0)
			n[num++]=i;
		return num;
}
int main()
{
	int i,m,ans1,ans2,ans3,min;
	__int64 cmp;
	cin>>m;
	min=INT_MAX;
	int num=factor(m);
	for(i=0;i<num;i++)
		for(int j=0;j<num;j++)
			for(int k=0;k<num;k++)
			{
				cmp=(__int64)n[i]*(__int64)n[j]*(__int64)n[k];
				if( cmp<INT_MAX && cmp>=m && ( n[i]*n[j] + n[i]*n[k] + n[j]*n[k] )<min )
					ans1=n[i],ans2=n[j],ans3=n[k],min=(n[i]*n[j]+n[i]*n[k]+n[j]*n[k]);
			}
			cout<<ans1<<' '<<ans2<<' '<<ans3<<endl;
			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