/
100.c
42 lines (38 loc) · 784 Bytes
/
100.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
int ara[1000000];
int main()
{
int i,j,m,l,count,a,b,x,Y,e,f;
while(scanf("%d %d",&i,&j)!= EOF){
if(i> j){
a = i;
b= j;
}
else {
a = j;
b = i;
}
for(m=b;m<=a;m++){
x = m;
count = 0;
while(x>1){
if(x%2 != 0){
x = 3*x + 1;
}
else {
x = x/2;
}
count ++;
}
ara[m] = count+1;
}
Y = 0;
for(l=b;l<=a;l++){
if(ara[l]>=Y){
Y = ara[l];
}
}
printf("%d %d %d\n",i,j,Y);
}
return 0;
}