思路:

根据异或的性质一位一位来搞。参考了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. I/O:Unit1

    编程,从键盘读入学生成绩(0~100分),共15名学生,计算并显示总分.平均成绩.单的学生成绩 ; sum: avg: DATA1 SEGMENT STU DB ,,,,,,,,,,,,,, SUM ...

  2. DS:template

    ylbtech-DS: 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   作者:ylbtech出处:http://ylbtech.cnbl ...

  3. ffmpeg 合并文件

    ffmpeg文件合并   文件1.ts~ 100.ts 流媒体文件1.txt 格式 file .ts file .ts ... file .ts 命 令   (-vcodec copy -acodec ...

  4. day1 java基础回顾-集合

    1.集合 1.1 集合的类型与各自的特性 ---|Collection: 单列集合 ---|List: 有存储顺序, 可重复 ---|ArrayList: 数组实现, 查找快, 增删慢 由于是数组实现 ...

  5. 关于Flask使用Celery的实践经验分享

      最近大Boss反馈Celery经常出现问题,几经实践终于把问题解决了!于是乎有了这篇博客的诞生,算是一个实践经验的分享吧! 软件版本如下: Celery () Flask () RabbitMQ( ...

  6. Django ORM 那些相关操作

    Django ORM 那些相关操作 一般操作 必知必会13条 <> all(): #查询所有的结果 <> filter(**kwargs) # 它包含了与所给筛选条件相匹配的对 ...

  7. Updatepanel 中使用 Timer 控件 失去焦点问题

    在Update Panel 中 如果使用timer 定时刷新数据,会造成textbox 或者其他控件的焦点丢失问题. 所以 text box 不能和timer 放在同一个Updatepanel 中. ...

  8. CodeChef - ELHIDARR Find an element in hidden array(二分交互)

    Find an element in hidden array There is an array of length N consisting of non-negative integers. T ...

  9. 权限验证MVC

    http://www.jb51.net/article/20147.htm  引用 <authentication mode="Forms"><!--权限受到阻碍 ...

  10. 给Fitnesse添加调用多参数fixture的调用方法

    修改文件:fitnesse.slim.fixtureInteraction.DefaultInteraction.java 修改如下三处内容: (注意只支持仅含有一个参数,且该参数是多参数的fixtu ...