HDU 1032 水题
/*
* Author:lonelycatcher
* problem:heu 1032
* type:纯水题
*/
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<string.h>
using namespace std;
int fun(int x)
{
int i=1;
while(x!=1)
{
if(x&1)
{
x=3*x+1;
}else
{
x=x>>1;
}
i++;
}
return i;
}
int main()
{
setbuf(stdout,NULL);
int left,right,max,i,j;
while(scanf("%d %d",&left,&right)!=EOF)
{
max=0;
if(left<right)
{
for(i=left;i<=right;i++)
{
int sum=fun(i);
if(sum>max)
{
max=sum;
}
}
}
else
{
for(i=right;i<=left;i++)
{
int f=fun(i);
if(f>max)max=f;
}
}
printf("%d %d %d\n",left,right,max);
}
return 0;
}
posted on 2011-08-01 08:14 lonelycatcher 阅读(218) 评论(0) 编辑 收藏 举报