http://acm.edu.cn/showproblem.php?pid=1032
直接用暴力方法竟然不超时...T_T感动cry ps:据说...自己算一下循环不超过10^6就不超时...囧
1 #include<stdio.h> 2 int main() 3 { 4 int a1,b1,a,b,i,j,count,t,s; 5 while(scanf("%d%d",&a,&b)!=EOF) 6 { 7 a1=a<b?a:b; 8 b1=a<b?b:a; 9 t=0; 10 for(i=a1;i<=b1;i++) 11 { 12 s=i; 13 count=1; 14 while(s!=1) 15 { 16 if(s%2==0) 17 {s=s/2;count++;} 18 else 19 { 20 s=3*s+1; 21 count++; 22 } 23 if(count>t) 24 t=count; 25 } 26 } 27 printf("%d %d %d ",a,b,t); 28 } 29 }