Go: 
package main

import (
	"fmt"
	"math"
)

func solve(n int) int {
	i := 0
	for {
		if val := math.Pow(2, float64(i)); val*2 > float64(n) {
			return int(val)
		}
		i++
	}
}

func main() {
	for {
		var n int
		_, err := fmt.Scan(&n)
		if err != nil {
			break
		}

		res := []int{}
		for {
			val := solve(n)
			res = append(res, val)
			n -= val

			if n <= 0 {
				break
			}
		}

		for i := range res {
			if i != 0 {
				fmt.Print(" ")
			}
			fmt.Print(res[len(res)-i-1])
		}
		fmt.Println()
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int n;
int main() {
	while(cin>>n){
		for (int i = 0; i < 11; ++i) {

			if(n%2){
				if(i!=0){
					cout<<' '<<pow(2,i);
				}else{
					cout<<pow(2,i);
				}
			}
			if(n==1)break;
			n=n/2;
		}
		cout<<endl;
	}
return 0;
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<bitset>
int main(){
    int t;
    while(std::cin>>t){
    std::bitset<11> value(t);
    std::string s=value.to_string();
    for(int i=0;i<s.size();i++){if(s[0]=='0') s.erase(s.begin()); else break;}
    int num=std::stoi(s);
        for(int i=0;i<s.size();i++){if(num%10){std::cout<<pow(2,(double)(i)); if(i!=s.size())std::cout<<" ";} num/=10;}
    std::cout<<std::endl;
    }
}

C++: #include <iostream>
using namespace std;

int main()
{
	int w,m,f;
	while(cin >> m)
	{
		f=w=1;
		while(m)
		{
			if(m&1)
			{
				cout << (f?"":" ") << w; f=0;
			}
			m = m>>1;
			w = w<<1;
		}
		cout << endl;
	}
}

C++:  
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int arr[10]={1,2,4,8,16,32,64,128,256,512}; 
  
 int main()
 {
   int N;
   while(cin>>N)
   {
     int count=0;
     int num[10]={0};
     while(N)
     {
       num[count++]=N%2;
       N/=2;        
     }      
     for(int i=0;i<count-1;i++)
     {
       if(num[i]) cout<<arr[i]<<" ";
     }
     if(num[count-1]) cout<<arr[i]<<endl;
     else cout<<endl;           
   }
   //while(1);     
   return 0;  
 }

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

typedef complex<double> P;

int main(){
	int n;
	while(cin>>n){
		bool f = true;
		for(int i = 0 ; i < 10 ; i++){
			if( !(n>>i&1) ) continue;
			if(!f) cout << " ";
			cout << (1<<i);
			f = false;
		}
		cout << endl;
	}
			
}

C++: #include <iostream>
using namespace std;

int main()
{
	int w=-1,m=-1;
	while(cin >> m)
	{
		w=1;
		while(m)
		{
			if(m&1) cout << w << " ";
			m = m>>1;
			w = w<<1;
		}
		cout << endl;
	}
}

C++: #include<iostream>
using namespace std;
int a[10] = {1,2,4,8,16,32,64,128,256,512};
int weight,b[11];


int main(){
  while(cin >> weight){
    int l = 0;
    for(int i = 0;i<10;i++)
      b[i] = 0;
    while(weight != 0){
      for(int i =9;i>=0;i--){
	if(weight >= a[i]){
	  weight = weight - a[i];
	  b[i] = 1;
	}
      }
    }
    for(int i=0;i<10;i++){
     
      if(b[i] == 1){
	   if(l != 0) cout << " ";
	   cout << a[i]; l++;
	}

    }
    cout << endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {
	int weight;

	while (cin >> weight) {
		vector<int> list;
		
		for (int i = 0;weight != 0;i++) {
			int candidate = pow(2, 9 - i);

			if (weight >= candidate) {
				list.push_back(candidate);
				weight -= candidate;
			}
		}

		int max = list.size() - 1;

		for (int j = 0;j < max; j++) {
			if (j != 0)cout << " ";
			cout << list.at(max - j);
		}
		cout << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <array>

using namespace std;

array< int, 10 > weight_array{ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
array< int, 1024 > sum_table;
array< array< int, 10 >, 1024 > bit_table;

void MakeTable()
{
	int i = 0, j = 0, tmp = 0;
	for ( i = 0 ; i < 1023 ; i++ )
	{
		tmp = i;
		for ( j = 0 ; j < 9 ; j++ )
		{
			sum_table[i] = ( tmp % 2 ) * weight_array[j] + sum_table[i];
			bit_table[i][j] = tmp % 2;
			tmp = tmp >> 1;
		}
	}
}

int main()
{
	int weight, j, i;
	MakeTable();

	cin >> weight;
	for ( i = 0 ; i < 1024 ; i++ )
	{
		if ( sum_table[i] == weight )
		{
			for ( j = 0 ; j < 10 ; j++ )
			{
				if ( bit_table[i][j] == 1 )
				{
					cout << weight_array[j];
				}
			}
			break;
		}
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int w;
	while(cin>>w)
	{
		bool flag=0;
		for(int i=1;w>0;i*=2)
		{
			if(w%2>0)
			{
				if(flag)
				{
					cout<<' ';
				}
				cout<<i;
				flag=1;
				w--;
			}
			w/=2;
		}
		cout<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  
  int n,b;
  int a[10],i;
  while(cin >> n){
    fill_n(a,10,1024);
    b = 512;
    i=0;
    
    while(n != 0){
      if(n >= b){
	a[i] = b;
	i++;
	n -= b;
      }
      b /= 2;
    }
    sort(a,a+10);
    for(int j = 0;j < i;j++){
      if(j == i-1) cout << a[j] << endl;
      else cout << a[j] << ' ';
    }
  }

  return (0);
}

C++: #include <iostream>
using namespace std;

int x;

void func(int p2, int y)
{
	int flag = 0;
	
	if (y == 0) {
		return;
	}
	
	if (y >= p2) {
		func(p2 / 2, y - p2);
		flag = 1;
	}
	else {
		func(p2 / 2, y);
	}
	
	if (flag == 1) {
		cout << p2;
	}
	if (y != x) {
		cout << ' ';
	}
}

int main()
{
	while (cin >> x) {
		func(512, x);
		cout << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int w[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	int flag[10] = {0};
	int g;
	bool f;
	
	while (cin >> g){
		for (int i = 9; i >= 0; i--){
			if (g >= w[i]){
				flag[i] = 1;
				g -= w[i];
			}
		}
		
		f = false;
		for (int i = 0; i < 10; i++){
			if (flag[i] == 1){
				if (f == true){
					cout << " ";
				}
				cout << w[i];
				if (f == false){
					f = true;
				}
			}
		}
		cout << endl;
	}
	
	return (0);
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
 
int main()
{
    const int weight[] = {1,2,4,8,16,32,64,128,256,512};
 
    std::vector<int> answer;
 
    int n;
 
    while(std::cin >> n)
    {
        for(size_t i=0; i<10; ++i)
        {
            if(n/weight[9-i])
            {
 
                answer.push_back(weight[9-i]);
 
                n = n%weight[9-i];
            }
        }
 
        for(size_t i=0; i<answer.size()-1; ++i)
        {
            std::cout << answer[answer.size()-1-i] << ' ';
        }
 
        std::cout << answer[0] << '\n';
 
        answer.clear();
    }
 
}
Compile Error Logs:

Status
Judge: 1/1 	C++ 	CPU: 00.00 sec 	Memory: 1212 [KB] 	Length: 476 [B] 	2012-08-29 02:02 	2012-08-29 02:02
Results for testcases
							
Case #1: 	: Accepted 	- 	- 	- 	NA 	- 	NA
< | 	1 	/ 	1 	| > 	  	 : Accepted        -        -
 
Input #1 ( ) 		Output #1 ( )

Not available.

		

Not available.

Comments
 
 Under Construction.
 
Categories
 
 
Free Tags

C++: #include<cstdio>
main(){int d,a;for(;a=1,~scanf("%d",&d);)for(;a<=d;a&d&&printf((d/a>2)?"%d ":"%d\n",a),a<<=1);}

C++: //C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
int v[30];
int main(){
  v[0]=1;
  for(int i=1;i<10;i++){
    v[i]=v[i-1]*2;
  }
  int s;
  while(cin>>s){
    vector<int> b;

    for(int i=9;i!=-1;i--){
      if(s==0)break;
      if(s>=v[i]){
        b.push_back(v[i]);
        s-=v[i];

      }
    }
    sort(b.begin(),b.end());
    for(int i=0;i<b.size()-1;i++){
      if(b[i])cout<<b[i]<<" ";
    }
    cout<<b[b.size()-1]<<endl;
    
  }

  return 0;
}