E题求助,求hack???

#include<bits/stdc++.h>
using namespace std;
#define inf 1e18
#define endl '\n'
#define int long long
typedef  long long ll;
typedef pair<int,int> pii;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int maxn=2e5+9;

void solve(){
	int n,x,y;
	cin >> n >> x >> y;
	if(n==1){
		if(x==y){
			cout << "YES" << endl;
			cout << x << endl;
		}else{
			cout << "NO" << endl;
		}
		return;
	}
	if((x|y)!=x){
		cout << "NO" << endl;
		return;
	}
	int a1=x,a2=x^y;
	cout << "YES" << endl;
	if(n==2){
		cout << a1 << " " << a2 << " ";
		cout << endl;
		return;
	}
	if(n==3){
		cout << x-(x&-x) << " " << a2 << " " << (x&-x) << endl;
		return;
	}
	
	cout << a1 << " " << a2 << " ";
	if((n%2==0)){
		for(int i=1;i<=n-2;i++) cout << x-(x&-x) << " ";
		cout << endl;
		return;
	}else{
		for(int i=1;i<=n-4;i++) cout << x-(x&-x) << " ";
		cout << x << " " << (x&-x);
		cout << endl;
		return;
	}
}


signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int t=1;
	cin >> t;
	while(t--){
		solve();
	}
	return 0;
}

全部评论
1 2 3 3
1 回复 分享
发布于 03-31 22:06 湖南

相关推荐

不愿透露姓名的神秘牛友
07-16 12:18
点赞 评论 收藏
分享
06-13 10:15
门头沟学院 Java
想去夏威夷的大西瓜在...:我也是27届,但是我现在研一下了啥项目都没有呀咋办,哎,简历不知道咋写
点赞 评论 收藏
分享
流浪的神仙:无恶意,算法一般好像都得9硕才能干算法太卷啦
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务