a414. 位元運算之進位篇

解法一

✅ 完整代碼

評分結果(參考) : AC (0.2s, 344KB)

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    while(cin >> n){
        if(n == 0) break;
        
        int cnt = 0;
        while(n&1){
            n >>= 1;
            cnt++;
        }
        
        cout << cnt << "\n";
    }
    
    return 0;
}