Răspuns:
#include <bits/stdc++.h>
using namespace std;
vector < int > ans;
int main()
{
int n;
cin >> n;
for(int i = 0 ; i <= 30 ; i++)
if(n & (1 << i))
ans.push_back(1 << i);
for(auto it : ans)
cout << it << " ";
cout << "\n";
return 0;
}
Explicație: