Created
October 14, 2017 08:06
-
-
Save henrybear327/29809f064267ad98b5907198a2ce1420 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#define sz(x) (int(x.size())) | |
typedef long long ll; | |
typedef double db; | |
int main() { | |
ll x; | |
while (scanf(" %lld", &x)) { | |
if (x == 0) break; | |
printf("%lld ", x); | |
ll mx = -1; | |
int i; | |
for (i = 0; ; i++) { | |
if (x & 1) { | |
x = 3 * x + 1; | |
} | |
else { | |
x = x / 2; | |
} | |
mx = max(mx, x); | |
if (x == 1) { | |
break; | |
} | |
} | |
printf("%d %lld\n", i + 1, mx); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment