题解 第二章暴力求解| #xxx定律#
xxx定律
http://www.nowcoder.com/practice/75c189249d6145cfa33cd53edae6afc8
冰雹猜想
3n+1猜想
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N = 0;
int StepNums = 0;
while (cin >> N)
{
if (!N)
break;
StepNums = 0;
while (N != 1)
{
StepNums++;
if (N % 2)
N = (3 * N + 1) / 2;
else
N /= 2;
}
cout << StepNums << endl;
}
return 0;
}
王道机试指南刷题 文章被收录于专栏
计划刷完这本书