思路:

根据异或的性质一位一位来搞。参考了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的更多相关文章

  1. 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的 ...

  2. cf1088D. Ehab and another another xor problem(思维)

    题意 题目链接 系统中有两个数\((a, b)\),请使用\(62\)以内次询问来确定出\((a, b)\) 每次可以询问两个数\((c, d)\) 若\(a \oplus c > b \opl ...

  3. 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 ...

  4. 【CF1174D】 Ehab and the Expected XOR Problem - 构造

    题面 Given two integers \(n\) and \(x\), construct an array that satisfies the following conditions: · ...

  5. CF D. Ehab and the Expected XOR Problem 贪心+位运算

    题中只有两个条件:任意区间异或值不等于0或m. 如果只考虑区间异或值不等于 0,则任意两个前缀异或值不能相等. 而除了不能相等之外,还需保证不能出现任意两个前缀异或值不等于m. 即 $xor[i]$^ ...

  6. codeforces#1157D. Ehab and the Expected XOR Problem(构造)

    题目链接: http://codeforces.com/contest/1174/problem/D 题意: 构造一个序列,满足以下条件 他的所有子段的异或值不等于$x$ $1 \le a_i< ...

  7. 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/ ...

  8. Codeforces.1088D.Ehab and another another xor problem(交互 思路)

    题目链接 边颓边写了半上午A掉啦233(本来就是被无数人过掉的好吗→_→) 首先可以\(Query\)一次得到\(a,b\)的大小关系(\(c=d=0\)). 然后发现我们是可以逐位比较出\(a,b\ ...

  9. CF1174D Ehab and the Expected XOR Problem

    思路: 使用前缀和技巧进行问题转化:原数组的任意子串的异或值不能等于0或x,可以转化成前缀异或数组的任意两个元素的异或值不能等于0或x. 实现: #include <bits/stdc++.h& ...

随机推荐

  1. WebSocket的C++服务器端实现

    由于需要在项目中增加Websocket协议,与客户端进行通信,不想使用开源的库,比如WebSocketPP,就自己根据WebSocket协议实现一套函数,完全使用C++实现. 代码已经实现,放在个人g ...

  2. POJ3264(线段树入门题)

    Balanced LineupCrawling in process... Crawling failed Time Limit:5000MS     Memory Limit:65536KB     ...

  3. JS--改变div大小

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  4. PCL推荐的命名规范(2)

    博客转载自:http://www.pclcn.org/study/shownews.php?lang=cn&id=210 函数/成员函数命名 函数和类的成员函数的命名应该采用camelCase ...

  5. HDU 5547 Sudoku (暴力)

    题意:数独. 析:由于只是4*4,完全可以暴力,要注意一下一些条件,比如2*2的小方格也得是1234 代码如下: #pragma comment(linker, "/STACK:102400 ...

  6. POJ - 3037 Skiing SPFA

    Skiing Bessie and the rest of Farmer John's cows are taking a trip this winter to go skiing. One day ...

  7. 结合webpack 一步一步实现懒加载的国际化简易版方案

    想法来源于工作需求,最后倒腾出一个国际化工作流,期望是这样的: 1. 自动化处理国际化文案(表现为转义翻译人员给到的文件处理成技术人员所识别的文件) 2. 转化后的国际化文件能够按需加载,实现懒加载的 ...

  8. Noip2016day1 天天爱跑步running

    题目描述 小c同学认为跑步非常有趣,于是决定制作一款叫做<天天爱跑步>的游戏.«天天爱跑步»是一个养成类游戏,需要玩家每天按时上线,完成打卡任务. 这个游戏的地图可以看作一一棵包含 个结点 ...

  9. Javascript 给table动态增、删除行

    操作 HTML DOM Table 对象 即可 http://www.runoob.com/jsref/dom-obj-table.html 动态给一个元素焦点,用focus()方法

  10. Java基础笔记(二)——配置环境变量

    https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 到此处下载jdk,并安装.(选 ...