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 |
思路很清晰,怎么错了?#include<iostream> #include<math.h> using namespace std; int l,w,h,t; void get(int n) { int i,j; l=0;w=0;h=0;t=0; if(((int)pow(n,1.0/3)+1)*((int)pow(n,1.0/3)+1)*((int)pow(n,1.0/3)+1)==n) {l=w=h=(int)pow(n,1.0/3)+1;return;}//由于(int)pow(n,1.0/3)并不等于3次方 for(i=(int)pow(n,1.0/3);i>=1;i--) { if(n%i==0) { h=i;t=n/i; for(j=(int)sqrt(t);j>=1;j--) { if(t%j==0) {l=j;w=t/j;break;} } break; } } return; } int main() { int m,n,area; cin>>m; while(m--) { cin>>n; get(n); area=2*(l*w+l*h+w*h); cout<<area<<endl; } getchar(); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator