Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:O(n^2) 和 O(n^1.5) 就是不一样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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator