| ||||||||||
| 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 | |||||||||
3n#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
int n=4;
int x,y;
while((cin>>x>>y))
{
int MAX=1;
if(x>10000||x<0||y>10000||y<0)
{
exit(1);
}
cout<<x<<' '<<y<<' ';
if(x>y)
{
int temp=y;
y=x;
x=temp;
}
for(int i=x;i<=y;i++)
{
int k=1,s=i;
while(s!=1)
{
if(s%2==1)
s=3*s+1;
else
s=s/2;
k++;
}
if(k>MAX)
{
MAX=k;
}
}
cout<<MAX<<endl;
}
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator