【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两种颜色的格子; 让你在这个格子 ...
随机推荐
- js---对象 和 函数this
一:对象创建的方法 //普通 字面量形式 var obj = { name:'名字', fn:function(){ console.log(this.name); } } //new 实例 var ...
- JS错误记录 - dom操作 - 排序
本次练习错误总结: 1. for循环要套到按钮的onclick里面,否则onclick点击事件无法依次执行. 2. var n1, var n2 这两个变量是arr.sort排序使用的,所以应该放在s ...
- date---显示或设置系统时间与日期
date命令可以用来显示或设定系统的日期与时间,格式设定为一个加号后接数个标记,其中可用的标记列表如下: 时间方面: %H : 小时(00..23) %M : 分钟(00..59) %p : 显示本地 ...
- poj 2503 哈希 Map 字典树
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 36967 Accepted: 15749 Descr ...
- 20亿与20亿表关联优化方法(超级大表与超级大表join优化方法)
记得5年前遇到一个SQL.就是一个简单的两表关联.SQL跑了几乎相同一天一夜,这两个表都非常巨大.每一个表都有几十个G.数据量每一个表有20多亿,表的字段也特别多. 相信大家也知道SQL慢在哪里了,单 ...
- 9.使用 npm 命令安装模块
转自:http://www.runoob.com/nodejs/nodejs-tutorial.html npm 安装 Node.js 模块语法格式如下: $ npm install <Modu ...
- ajax嵌套ajax 可能出现问题 的解决办法
ajax由于他的异步特性 在第一次请求中的循环中嵌套第二个ajax会数据会读不出来 第一种 描述:如果条件许可,把两次请求都放在服务端处理掉一起发回来,这些就在客户端只有一次ajax了 优点:代码放在 ...
- BZOJ1576: [Usaco2009 Jan]安全路经Travel(树链剖分)
Description Input * 第一行: 两个空格分开的数, N和M * 第2..M+1行: 三个空格分开的数a_i, b_i,和t_i Output * 第1..N-1行: 第i行包含一个数 ...
- Docker 内程序时间设置,很重要
原文:Docker 内程序时间设置,很重要 重要!!!!! 创建容器时候需要修改一个参数,设置tomcat的时区 -e TZ="Asia/Shanghai" -v /etc/loc ...
- java list 容器的ConcurrentModificationException
java中的很多容器在遍历的同时进行修改里面的元素都会ConcurrentModificationException,包括多线程情况和单线程的情况.多线程的情况就用说了,单线程出现这个异常一般是遍历( ...