| ||||||||||
| 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+1Int compute1(int i)
{
Int count=1,tmp=i;
While(tmp>1)
{
If(tmp %2 =0) tmp/=2;
Else tmp=3*tmp+1;
count++
}
Return count;
}
Int compute2(int i, int j)
{
int max=0,tmp;
for(k=i;k<=j;k++)
{
tmp=compute1(k)
if (max<tmp) max=tmp;
}
Return max;
}
#include “stdio.h”
int main(void)
{
int I,j result;
While(scanf(%d,&i)!=null)
{
scanf(%d,&j);
result=compute2(I,j);
printf(“%d %d %d”,I,j,result);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator