PAT乙级1001
https://pintia.cn/problem-sets/994805260223102976/problems/994805325918486528
#include<bits/stdc++.h> using namespace std; int n,sum; int main() { cin>>n; while(n!=1) { if(n&1) n=(3*n+1)/2; else n/=2; sum++; } cout<<sum; return 0; }
https://pintia.cn/problem-sets/994805260223102976/problems/994805325918486528
#include<bits/stdc++.h> using namespace std; int n,sum; int main() { cin>>n; while(n!=1) { if(n&1) n=(3*n+1)/2; else n/=2; sum++; } cout<<sum; return 0; }