結果

提出番号 694
提出者 Siri
言語 C++
提出日時 2017-08-01 13:38:03
問題名 (46)未解決問題
結果 AC
点数 100%

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 AC 100% 2ms 7984KB
2 AC 100% 1ms 8320KB
3 AC 100% 2ms 7696KB
4 AC 100% 2ms 8304KB
5 AC 100% 2ms 8304KB
6 AC 100% 2ms 7504KB
7 AC 100% 2ms 8336KB
8 AC 100% 2ms 8320KB
9 AC 100% 2ms 8320KB
10 AC 100% 1ms 8000KB

ソースコード

#include<iostream>
#include<list>
#include<climits>
#include<string>
#include<algorithm>
#include<functional>

using namespace std;

long long int n, x, a;

int main() {
	cin >> n;
	a = n;
	if (a == 1) {
		cout << x << endl;
		return 0;
	}
	for (int i = 1;; i++) {
		if (a % 2 == 0) {
			a /= 2;
		}
		else {
			a = 3 * a + 1;
		}
		x++;
		if (a == 1) {
			cout << x << endl;
			return 0;
		}
	}
}