| ||||||||||
| 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 | |||||||||
为什么会有OLE ,第二次就好了,真是无语#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdio>
using namespace std;
int caculate(int num)
{
int no=1;
if(num==1)
return no;
else
{
while(num!=1)
{
if(num%2==0)
num/=2;
else
num=num*3+1;
no++;
}
}
return no;
}
int main(int argc, char const *argv[])
{
int m,n;
while(cin>>m>>n)
{
int tM=m,tN=n;
if(m>n)
{
int t=m;
m=n;
n=t;
}
int maxn=0;
for(int i=m;i<=n;i++)
maxn=max(maxn,caculate(i));
cout<<tM<<" "<<tN<<" "<<maxn<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator