#include<stdio.h>
int sum;
int fac(int n){
if(n==1)return sum;
else if(n%2==0){n=n/2;sum++;}
else if(n%2!=0){n=3*n+1;sum++;}
return fac(n);
}
int main(void){
int i,j,n,k,temp,temp2;
while(scanf("%d%d",&i,&j)!=EOF){
printf("%d %d",i,j);
if(i>j){k=i;i=j;j=k;}
sum=1;
temp=fac(i);
for(k=i+1;k<=j;k++){
sum=1;
temp2=fac(k);
if(temp<temp2)temp=temp2;
}
printf(" %d\n",temp);
}
return 0;
}
HDU-1032
最新推荐文章于 2019-12-15 03:05:06 发布