View Code of Problem 3700

#include<iostream>
#include<cmath>
using namespace std;

int main()
{
    int bit[50] = {0};
    int a,n;
    while (cin >> n){
        if(n == 0) break;
        int i = 0;
        while(n != 0){
            bit[i++] = n % 2;
            n = n / 2;
        }
        for(int j = 0; j < i ; j++){
            if(bit[j] != 0){
                cout << pow(2,j) << endl;
                break;
            }
        }
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 3700