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:都已经是暴力了怎么还WA。。。In Reply To:都已经是暴力了怎么还WA。。。 Posted by:x1e398u at 2005-11-28 14:05:52 > #include <stdio.h> > #include <math.h> > > int main() > { > int T; > scanf("%d",&T); > for(;T>0;T--) > { > int N; > scanf("%d",&N); > int tmp=N; > if(N==0) > { > printf("0\n"); > continue; > } > int a=pow(N,1.0/3)+1,b,c,min=10000; //a 多加1就没事 ,还有下面的b也是 > for(;a>0;a--) > if(N%a==0) > { > int tmp=N; > tmp/=a; > for(b = sqrt(tmp)+1;b>0;b--) > if(tmp%b==0) > { > c=tmp/b; > if(min>((a*b+b*c+c*a)<<1)) min=(a*b+b*c+c*a)<<1; //这里可以直接跳出外面循环!!!! > } > } > printf("%d\n",min); > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator