Từ Lớp lập trình thi Chuyên Tin 2025 2026, HSG Tỉnh Thanh Hoá
Thông tin
include <bits/stdc++.h>
using namespace std; int main(){ iosbase::syncwith_stdio(false) ; cin.tie(nullptr) ; int n , d = 0 ; cin >> n ; if(n % 2 == 0){ while(n > 0){ n = n / 2 ; d++ ; if(n == 1){ break ; } } cout << d ; } else{ while(n > 0){ n = 3 * n + 1 ; d++ ; if(n == 1){ break ; } } cout << d ; } return 0 ; }