PAT (Basic Level) Practise 1001

https://www.patest.cn/contests/pat-b-practise/1001


#include 

int main() {
    int input, count = 0;

    std::cin >> input;
    while(input != 1) {
        count++;
        if (input % 2 == 0)
            input /= 2;
        else
            input = (input * 3 + 1) / 2;
    }
    std::cout << count << std::endl;

    return 0;
}

 

你可能感兴趣的:(OnlineJudge)