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:高手帮我看看,怎么想也没发现问题,连0我都算了,怎么还wa啊?这个肯定不会超时的啦,因为我。。。

Posted by cxj666 at 2015-08-16 17:21:00 on Problem 2363
In Reply To:高手帮我看看,怎么想也没发现问题,连0我都算了,怎么还wa啊?这个肯定不会超时的啦,因为我。。。 Posted by:radish at 2005-04-02 22:15:38
> #include<iostream.h>
> #include<math.h>
> int prime[168]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
> int main()
> {
>     int i,j,k,m,n;
>     cout<<prime[95];
>     cin>>n;
>     while(n)
>     {
>         cin>>m;
>         if(m==0){cout<<0<<endl;goto next;}
>         if(m==1){cout<<6<<endl;goto next;}
>         for(i=0;i<168;i++)//长宽都是1
>         if(m==prime[i]){cout<<m*4+2<<endl;goto next;}
>         for(i=0;i<11;i++)//长是1
>         if(m%prime[i]==0)
>         {
>             k=m/prime[i];for(j=0;j<95;j++)
>             if(k==prime[j]){cout<<2*prime[i]*k+2*(prime[i]+k)<<endl;goto next;}
>         }
>         for(i=int(ceil(pow(m,1.0/3)));i>1;i--)//长宽高都不是1,至少长宽高有一个小于n的立方根,设为高
>         if(m%i==0)
>         {
>             m=m/i;
>             for(j=int(ceil(pow(m,0.5)));j>=2;j--)if(m%j==0)//高是1,长宽都不是1,至少长宽有一个小于n的平方根,设为长
>             {k=m/j;cout<<2*(i*j+j*k+k*i)<<endl;goto next;}
>         }
> next:   n--;
>     }
>     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