Problem link:
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=36
/***********************************************************************\
|*********S*** ****** ************* ************ ************** ******|
|*********** ******** ************ ************ *********** ** ******|
|********* ********** *********** *** ********** * ********* *** ******|
|******** *********** *I******** **** ********** *** ***** ***** ******|
|******** *********** ********* ****** ********* ***** ** ****** ******|
|********** ********* ******** ***A**** ******** ******* ******* ******|
|*********** ******** ******* ********** ******* *************** ******|
|********** ********* ****** ************ ****** *************** ******|
|******** *********** ***** ************** ***** ********M****** ******|
|***** ************** **** **************** **** *************** ******|
|***********************************************************************|
|**************BSMRSTU********************************CSE***************|
\***********************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<conio.h>
#include<stdlib.h>
#define ll long long
#define B break
#define C continue
#define sf scanf
#define pf printf
#define byebye return 0
int main()
{
int a,b;
while(sf("%d%d",&a,&b)!=EOF)
{
pf("%d %d",a,b);
if(a>b){
int n=a;
a=b;
b=n;
}
int i,j,total=0;
for(i=a; i<=b; i++)
{
int count=1;
j=i;
while(j!=1)
{
if(j%2)
{
j=(3*j)+1;
}
else
{
j=j/2;
}
count++;
}
if(total<count)
total=count;
}
pf(" %d\n",total);
}
byebye;
}
Pastebin Link : http://pastebin.com/9RZ9nNXm
0 comments:
Post a Comment