80分求调
查看原帖
80分求调
684890
Rhss楼主2023/4/5 13:16
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
ll n;
vector<ll> ans;
int lowbit(int x) {
	return x & -x;
}
int main()
{
	cin >> n;
	while(n)
	{
		ll k = lowbit(n);
		n -= k;
		ans.push_back(k);
	}
	cout << ans.size() << endl;
	for(int i = 0 ; i < ans.size() ; ++i) cout << ans[i] << ' ';
	return 0;
}
2023/4/5 13:16
加载中...