- A+
所属分类:ACM
杭电ACM1032
#include <iostream>
int main()
{
int i,j;
int count,max;
int n,temp;
using namespace std;
while (cin >> i >> j)
{
max=0;
cout << i << " " << j << " " ;
if (i>j)
{
temp=i;
i=j;
j=temp;
}
for (n=i;n<=j;n++)
{
count=1;
temp=n;
while (temp!=1)
{
count++;
if (temp%2==1)
{
temp=3*temp+1;
}
else
{
temp=temp/2;
}
}
if (count>max)
{
max=count;
}
}
cout << max << endl;
}
return 0;
}
该题只需注意下输出格式,其他的看懂题目就没啥大问题了.