奇怪,大佬救命
查看原帖
奇怪,大佬救命
1106289
KomorKomor楼主2024/7/19 21:38
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#define ll long long 
using namespace std;

void solve()
{
	ll n;	cin>>n;
	int one=__builtin_popcount(n);

	if(one==1)
	{
		cout<<1<<endl;
		cout<<n<<endl;
	}

	else 
	{
		cout<<one+1<<endl;
		
		for(int i=62;i>=0;i--)
		{
			if(n>>i&1)
				cout<<(n^(1LL<<i))<<' ';
		}
		cout<<n<<endl;	
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);	cout.tie(0);

	int t=1;	cin>>t;
	while(t--)	solve();

	return 0;
}

cf说第二个测试点 Wrong answer not longest(testcase 101) 没搞懂为什么

2024/7/19 21:38
加载中...