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 jackch at 2006-09-09 11:44:39 on Problem 2363
#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:
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