玄学AC
查看原帖
玄学AC
197950
阿斯蒂芬呀楼主2020/11/8 12:32
#include <cctype>
#include <stdio.h>
//#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int INF = 0x6fffffff;
const int N = 1e5 + 5;

int n;
int a[N], cnt;

int main() {
	ios :: sync_with_stdio(false);
    cin >> n;
    if (n % 2 == 1) {
    	cout << -1 << endl;
    	return 0;
	}
	int now = 1;
	while (n) {
		now <<= 1, n >>= 1;
		if (n & 1 == 1) a[++ cnt] = now;
	}
	for (int i = cnt; i > 0; -- i)
		cout << a[i] << ' ';
	cout << endl;
	return 0;
}

2020/11/8 12:32
加载中...