-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path100.cpp
More file actions
62 lines (49 loc) · 1.12 KB
/
100.cpp
File metadata and controls
62 lines (49 loc) · 1.12 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// @BEGIN_OF_SOURCE_CODE
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define pi acos(-1.0)
#define N 1000000
#define long long LL
using namespace std;
int main ()
{
int i, j;
while ( scanf ("%d %d", &i, &j) != EOF ) {
int temp_i = i;
int temp_j = j;
if ( i > j ) swap (i, j);
int max_cycle_length = 0;
int cycle_length;
while ( i <= j ) {
int n = i;
cycle_length = 1;
while ( n != 1 ) {
if ( n % 2 == 1 ) n = 3 * n + 1;
else n /= 2;
cycle_length++;
}
if ( cycle_length > max_cycle_length )
max_cycle_length = cycle_length;
i++;
}
printf ("%d %d %d\n", temp_i, temp_j, max_cycle_length);
}
return 0;
}
// @END_OF_SOURCE_CODE