【Codeforces Round #435 (Div. 2) C】Mahmoud and Ehab and the xor
【链接】h在这里写链接
【题意】
【题解】
如果n==1;
输出x就好;
如果n==2;
如果x==0,无解。
如果x!=0,输出一个0,输出一个x.
如果n==3
如果x==0,输出(1<<17)|x,(1<<17)|(1<<18),1<<18
如果x!=0,输出(1<<17)|x,(1<<17)|(1<<18),1<<18
如果n>3
设temp = 1^2^...^n-3
则令n=3,x = x ^ temp
再做一遍n=3的情况就好
*/
【错的次数】
【反思】
【代码】
#include <bits/stdc++.h>
using namespace std; int n, x,now; void deal(int x) {
cout << ((1 << 17) | x) << ' ' << ((1 << 17) | (1 << 18)) << ' ' << (1 << 18) << endl;
now ^= x;
} int main() {
//freopen("F:\\rush.txt", "r", stdin);
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> x;
if (n == 1) {
cout << "YES" << endl;
cout << x << endl;
return 0;
}
if (n == 2) {
if (x == 0)
return cout << "NO" << endl, 0;
else
return cout << "YES" << endl << "0 " << x << endl, 0;
}
if (n == 3) {
cout << "YES" << endl;
deal(x);
return 0;
}
cout << "YES" << endl;
int temp = 0;
for (int i = 1; i <= n - 3; i++)
temp^=i,cout << i << ' ',now^=i;
deal(x^temp);
return 0;
}
【Codeforces Round #435 (Div. 2) C】Mahmoud and Ehab and the xor的更多相关文章
- 【Codeforces Round #435 (Div. 2) A】Mahmoud and Ehab and the MEX
[链接]h在这里写链接 [题意] 在这里写题意 [题解] 让x没有出现,以及0..x-1都出现就可以了. [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/std ...
- 【Codeforces Round #435 (Div. 2) B】Mahmoud and Ehab and the bipartiteness
[链接]h在这里写链接 [题意] 让你在一棵树上,加入尽可能多的边. 使得这棵树依然是一张二分图. [题解] 让每个节点的度数,都变成二分图的对方集合中的点的个数就好. [错的次数] 0 [反思] 在 ...
- 【Codeforces Round #435 (Div. 2) A B C D】
CF比赛题目地址:http://codeforces.com/contest/862 A. Mahmoud and Ehab and the MEX ·英文题,述大意: 输入n,x(n,x& ...
- 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
- 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes
[题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...
- 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees
[题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...
- 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
[题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...
- 【Codeforces Round #423 (Div. 2) C】String Reconstruction
[Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...
- 【Codeforces Round #423 (Div. 2) B】Black Square
[Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...
随机推荐
- Sco Unixware 7.1.3企业版服务器安装视频教程
Sco Unixware 7.1.3企业版服务器安装视频教程 UnixWare 7.1.3是最先进的工业标准Intel和AMD处理器系统运行平台.UnixWare 7.1.3是关键业务解决方案的可靠基 ...
- spark源码编译,本地调试
1.下载源码 2.进入源码根据README.md编译源码,注意使用的是源码目录下的maven编译 3.用idea导入顶层pom文件 4.修改顶层pom文件和example下的pom文件,将scope的 ...
- c# 用代码来设置程序的PrivatePath
原文:c# 用代码来设置程序的PrivatePath 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/sweety820/article/detail ...
- Codeforces 441 B. Valera and Fruits
B. Valera and Fruits time limit per test 1 second memory limit per test 256 megabytes input standard ...
- java——简单理解线程
一·[概念] 一般来说,我们把正在计算机中运行的程序叫做"进程"(process),而不将其称为"程序"(program). 所谓"线程& ...
- Linux 内存管理与系统架构设计
Linux 提供各种模式(比如,消息队列),但是最著名的是 POSIX 共享内存(shmem,shared memory). Linux provides a variety of schemes ( ...
- 借Stunnel工具保护E-mail服务器
借Stunnel工具保护E-mail服务器 650) this.width=650;" onclick='window.open("http://blog.51cto.com/vi ...
- activity 接回返回值
activity 接回返回值 今天做订单列表显示 点击某一项显示订单详细信息,在详细activity中用户可以选择取消订单(未支付的状态下)当用户取消订单后订单列表也要改变状态,原来最初做法是所加载绑 ...
- Vue render: h => h(App) $mount
$mount()手动挂载 当Vue实例没有el属性时,则该实例尚没有挂载到某个dom中: 假如需要延迟挂载,可以在之后手动调用vm.$mount()方法来挂载.例如: new Vue({ //el: ...
- [D3JS] Add more map layer and color
import React, {Component} from 'react'; import * as d3 from 'd3'; import 'd3-geo'; import * as topoj ...