You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
438 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
const int N = 32;
int a[N], al;
int main() {
int n;
cin >> n;
if (n % 2) {
puts("-1");
exit(0);
}
// 将x拆分成二进制形式用数组装起来
while (n) {
a[++al] = n % 2;
n /= 2;
}
for (int i = al; i; i--) // 由高位到低位
if (a[i]) printf("%d ", 1 << (i - 1));
return 0;
}