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:O(n^2) 和 O(n^1.5) 就是不一样

Posted by 810974380 at 2009-07-24 09:19:56 on Problem 2363
In Reply To:O(n^2) 和 O(n^1.5) 就是不一样 Posted by:seu_enic at 2009-04-02 15:37:29
> 呵呵,用了你的方法暴搜 

#include<iostream>
using namespace std;
int f(int n)
{ int i,j,k,s,min=10000;
 for(i=1;i<=n;i++)
   for(j=i;i*j<=n;j++)
	if(n%(i*j)==0) 
	{ k=n/i/j;
	s=2*(i*j+j*k+i*k);
	if(s<min) min=s;}
  return min;
}
int main()
{ int num,x;
  cin>>num;
  while(num--)
  { cin>>x; 
  cout<<f(x)<<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