-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuva-100.c
46 lines (37 loc) · 869 Bytes
/
uva-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
43
44
45
46
#include <stdio.h>
int main()
{
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
unsigned long long i, j, a, b, n, m;
int count, max;
while (scanf("%llu%llu", &i, &j) != EOF) {
if (i >= j) {
a = j;
b = i;
}
else {
a = i;
b = j;
}
max = 0;
for (n = a; n <= b; n++) {
count = 1;
m = n;
while (m != 1) {
if (m % 2 == 0) {
m /= 2;
}
else {
m = 3 * m + 1;
}
count++;
}
if (count > max) {
max = count;
}
}
printf("%llu %llu %d\n", i, j, max);
}
return 0;
}