2012年7月6日金曜日

AOJ Volume0 0031: Weight

/***********************
*  2012/07/04          *
*  AOJ Volume0 0031    *
*  Weight              *
*  crane               *
************************/

//---------------------------//
//       2 )  6   ---0       //
//         ------            //
//       2 )  3   ---1       //
//         ------            //
//            1              //
//---------------------------//
#include<iostream>
#include<cmath>
using namespace std;

int main(){
    int n;
    while(cin >> n){
        int count = 0;
        bool f = false;
        while(n != 1){
            if(n%2 == 1){
                if(f) cout << " " << pow(2.0, count);
                else{
                    f = true;
                    cout << pow(2.0,count);
                }
            }
            n/=2;
            count++;
        }
        if(f) cout << " ";
        cout << pow(2.0, count) << endl;
    }
    return 0;
}

0 件のコメント:

コメントを投稿