题解
2025-01-21 22:41:15
发布于:广东
5阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int a[1100];
int main(){
int n, x = 0, y = 0;
bool flag = false;
cin >> n;
if(n % 2 == 1){
cout << -1 << endl;
return 0;
}
else{
while(n != 0){
n /= 2;
x++;
if(n % 2 == 1){
a[y] = pow(2, x);
}
y++;
}
}
for(int i = y - 1; i >= 0; i--){
if(a[i] != 0){
cout << a[i] << " ";
}
}
return 0;
}
这里空空如也
有帮助,赞一个