CF1088D Ehab and another another xor problem
思路:
根据异或的性质一位一位来搞。参考了https://blog.lucien.ink/archives/362/
实现:
#include <bits/stdc++.h>
using namespace std;
void out(char x, int a, int b)
{
cout << x << " " << a << " " << b << endl;
fflush(stdout);
}
int main()
{
int a, b;
char big = 'a';
out('?', , );
cin >> a;
if (a == -) big = 'b';
int x = , y = ;
for (int i = ; i >= ; i--)
{
int t = << i;
x |= t; y &= ~t;
out('?', x, y);
cin >> a;
x ^= t; y ^= t;
out('?', x, y);
cin >> b;
if (a == - && b == )
{
x |= t; y |= t;
}
else if (a == && b == -)
{
x &= ~t; y &= ~t;
}
else if (a == b)
{
if (big == 'a')
{
x |= t; y &= ~t;
if (a == -) big = 'b';
}
else
{
x &= ~t; y |= t;
if (a == ) big = 'a';
}
}
}
out('!', x, y);
return ;
}
CF1088D Ehab and another another xor problem的更多相关文章
- 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的 ...
- cf1088D. Ehab and another another xor problem(思维)
题意 题目链接 系统中有两个数\((a, b)\),请使用\(62\)以内次询问来确定出\((a, b)\) 每次可以询问两个数\((c, d)\) 若\(a \oplus c > b \opl ...
- 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 ...
- 【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(待完成)
参考资料: [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\ ...
- CF1174D Ehab and the Expected XOR Problem
思路: 使用前缀和技巧进行问题转化:原数组的任意子串的异或值不能等于0或x,可以转化成前缀异或数组的任意两个元素的异或值不能等于0或x. 实现: #include <bits/stdc++.h& ...
随机推荐
- 更换mysql数据目录后出现 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 的解决办法
服务器上的mysql默认数据目录为/var/lib/mysql/,同时服务器的/空间不是很大,而近期又有大量的日志需要导入进行分析,时常搞得/的空间捉襟见肘,晚上一狠心就想把mysql的数据目录转移到 ...
- Spring boot 学习 四:spring boot 配置文件 application.yml
一 关于端口: spring boot的默认端口是8080, 如果想更改的话,在配置文件中做如下配置.ServerProperties.class会去读取这个值. server: port: 另外一种 ...
- WPF系列学习之三(路由事件)
路由事件实际上以一上 列三种方式出现. 1.与普通的.net事件类似的直接路由事件.它们起源于一个元素,并且不传递给其他元素.例如:MouseEnter事件. 2.在包含层次中向上传递的冒 ...
- PCL中异常处理机制
博客转载自:http://www.pclcn.org/study/shownews.php?lang=cn&id=287 本节我们主要讨论PCL在编写和应用过程中如何利用PCL的异常机制,提高 ...
- java Class类
java Class类 Class类(在java.lang包中,Instances of the class Classrepresent classes and interfaces in a ru ...
- Object有哪些公用的方法?
Object是所有类的父类,任何类都默认继承Object. public class Demo { public static void main(String[] args) { Object ob ...
- HDU - 3664 Permutation Counting 排列规律dp
Permutation Counting Given a permutation a1, a2, … aN of {1, 2, …, N}, we define its E-value as the ...
- Software - (转)Winform 程序捕获全局异常
static class Program { /// <summary> /// 应用程序的主入口点. /// </summary> [STAThread] static vo ...
- npm ERR! mathine_call@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js` npm ERR! Exit status 1
internal/modules/cjs/loader.js:583 throw err; ^ Error: Cannot find module 'webpack' at Function.Modu ...
- unity_pojie
http://www.ceeger.com/forum/read.php?tid=23396&desc=1