Files
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

30 lines
621 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
// 奇数直接输出-1
if (n % 2) {
cout << -1 << endl;
return 0;
}
vector<int> powers;
// 从高位到低位检查每一位(2^1到2^30)
for (int i = 30; i >= 1; --i) {
int power = 1 << i; // 计算2^i
if (n >= power) {
powers.push_back(power);
n -= power;
}
}
// 输出结果
for (int i = 0; i < powers.size(); i++) {
if (i > 0) cout << " ";
cout << powers[i];
}
return 0;
}