PAT 乙级 1001 害死人不偿命的(3n+1)猜想(模拟)

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    int cnt = 0;
    while (n != 1) {
        if (n & 1) n = (3 * n + 1) / 2;
        else n /= 2;
        ++cnt;
    }
    cout << cnt << "\n";
}

 

posted @ 2020-06-18 22:10  Kanoon  阅读(126)  评论(2)    收藏  举报