魔法数字变换
魔法数字变换
https://ac.nowcoder.com/acm/problem/22163
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
int n;
cin >> n;
int step = 0;
while (n != 1)
{
if (n % 2 == 0)
n = n / 2;
else
n = n * 3 + 1;
step++;
}
cout << step;
return 0;
}
汤臣倍健公司氛围 434人发布