CF1174D Ehab and the Expected XOR Problem
思路:
使用前缀和技巧进行问题转化:原数组的任意子串的异或值不能等于0或x,可以转化成前缀异或数组的任意两个元素的异或值不能等于0或x。
实现:
#include <bits/stdc++.h>
using namespace std;
int vis[ << ];
int main()
{
int n, x;
while (cin >> n >> x)
{
memset(vis, , sizeof vis);
vector<int> v;
if (x >= ( << n))
{
for (int i = ; i < ( << n); i++) v.push_back(i);
}
else
{
for (int i = ; i < ( << n); i++)
{
if (i == x) continue;
else if (!vis[i]) { v.push_back(i); vis[i ^ x] = ; }
}
}
cout << v.size() << endl;
if (!v.empty())
{
cout << v[] << " ";
for (int i = ; i < (int)v.size(); i++) cout << (v[i - ] ^ v[i]) << " ";
cout << endl;
}
}
return ;
}
CF1174D Ehab and the Expected XOR Problem的更多相关文章
- CF1174D Ehab and the Expected XOR Problem(二进制)
做法 求出答案序列的异或前缀和\(sum_i\),\([l,r]\)子段异或和可表示为\(sum_r\bigoplus sum_{l-1}\) 故转换问题为,填\(sum\)数组,数组内的元素不为\( ...
- 【CF1174D】 Ehab and the Expected XOR Problem - 构造
题面 Given two integers \(n\) and \(x\), construct an array that satisfies the following conditions: · ...
- CF D. Ehab and the Expected XOR Problem 贪心+位运算
题中只有两个条件:任意区间异或值不等于0或m. 如果只考虑区间异或值不等于 0,则任意两个前缀异或值不能相等. 而除了不能相等之外,还需保证不能出现任意两个前缀异或值不等于m. 即 $xor[i]$^ ...
- codeforces#1157D. Ehab and the Expected XOR Problem(构造)
题目链接: http://codeforces.com/contest/1174/problem/D 题意: 构造一个序列,满足以下条件 他的所有子段的异或值不等于$x$ $1 \le a_i< ...
- Codeforces Round #525 (Div. 2)D. Ehab and another another xor problem
D. Ehab and another another xor problem 题目链接:https://codeforces.com/contest/1088/problem/D Descripti ...
- cf1088D Ehab and another another xor problem (构造)
题意:有两数a,b,每次你可以给定c,d询问a xor c和b xor d的大小关系,最多询问62次($a,b<=2^{30}$),问a和b 考虑从高位往低位做,正在做第i位,已经知道了a和b的 ...
- Codeforces Round #563 (Div. 2) E. Ehab and the Expected GCD Problem
https://codeforces.com/contest/1174/problem/E dp 好题 *(if 满足条件) 满足条件 *1 不满足条件 *0 ///这代码虽然写着方便,但是常数有点大 ...
- Codeforces Round #525 (Div. 2) D. Ehab and another another xor problem(待完成)
参考资料: [1]:https://blog.csdn.net/weixin_43790474/article/details/84815383 [2]:http://www.cnblogs.com/ ...
- Codeforces.1088D.Ehab and another another xor problem(交互 思路)
题目链接 边颓边写了半上午A掉啦233(本来就是被无数人过掉的好吗→_→) 首先可以\(Query\)一次得到\(a,b\)的大小关系(\(c=d=0\)). 然后发现我们是可以逐位比较出\(a,b\ ...
随机推荐
- 报错:Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): cn.itcast.bos.domain.base.SubArea
因为 实体类中的主键 是String类型 不能自动为其分配id 所以需要手动设置在service层 model.setId(UUID.randomUUID().toString());
- ubuntu server usb安装盘制作问题
本来服务器上装的是windows server 2003,开多个虚拟机装linux来用,但发现不管是vmware还是virtualbox,总是有内存泄漏,大约2个星期左右16G内存就全没了,任务管理器 ...
- linux上运行jmeter-server失败
1. 在linux上运行jmeter-server报如下错误 处理办法: 通过如下命令运行 ./jmeter-server -Djava.rmi.server.hostname=192.168.16. ...
- UCSC数据库数据调用cruzdb
https://github.com/Wy2160640/cruzdb UCSC基因组数据库是注释,调节和变异以及越来越多的分类群的各种数据的重要资源. 该库旨在简化数据的利用,以便我们可以进行复杂的 ...
- AQS(AbstractQueuedSynchronizer)介绍-01
1.概述 AQS( AbstractQueuedSynchronizer ) 是一个用于构建锁和同步器的框架,许多同步器都可以通过AQS很容易并且高效地构造出来.如: ReentrantLock 和 ...
- XLua 基础
一.Lua文件加载 1.Resources文件夹下加载 xxx.lua.txt 文件 1.)Resources加载xuaTest文件 // 1.Resources加载xuaTest文件 TextA ...
- CEPH安装教程(下)
创建 CEPH 文件系统 创建存储池 # ceph osd pool create cephfs_data 64 # ceph osd pool create cephfs_metadata 64 创 ...
- 2017-11-7 NOIP模拟赛
1.数学老师的报复 #include<iostream> #include<cstdio> using namespace std; int cnt; ]; long long ...
- Spring MVC 基于Method的映射规则(注解版)
在Restful风格的web开发中,根据不同的请求方法使用相应的控制器处理逻辑成为核心需求,下面就看看如何在Spring MVC中识别不同的请求方法. 请求方法 在Http中,请求的方法有很多种,最常 ...
- 多线程中wait、notify理解
实在惭愧,java开发多年,多线程运用一直不多,该知识点理解也不够,不怎么会用.赶上使用多线程 生产者.消费者模式,学习下该知识点. synchronized 获取锁 wait 阻塞本线程,释放对象 ...