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& ...
随机推荐
- BZOJ3295:[CQOI2011]动态逆序对
浅谈树状数组与线段树:https://www.cnblogs.com/AKMer/p/9946944.html 题目传送门:https://www.lydsy.com/JudgeOnline/prob ...
- 设置一个.exe文件开机启动
运行"regedit",编辑注册表 HKEY_LOCAL_MACHINE -- SOFTWARE -- Microsoft -- Windows -- CurrentVersion ...
- 【转】android adb常用指令
Android 调试桥(adb)是多种用途的工具,该工具可以帮助你你管理设备或模拟器 的状态. 可以通过下列几种方法加入adb: 在设备上运行shell命令 通过端口转发来管理模拟器或设备 从模拟器或 ...
- 网络工具 NetCat
http://netcat.sourceforge.net/ windows 版本 https://joncraton.org/blog/46/netcat-for-windows/ https:// ...
- 'xxx' declared `static' but never defined
'xxx' declared `static' but never defined [问题描述] uart.c文件中有函数read_sample的实现: [plain] view plain copy ...
- java注解总结(1)
1.什么是注解 注解,主要提供一种机制,这种机制允许程序员在编写代码的同时可以直接编写元数据. 2.介绍 何为注解?--->元数据:描述数据自身的数据. 注解就是代码的元数据,他们包含了代码自身 ...
- ASP.NET Core会议管理平台实战_4、参数校验、操作结果封装,注册参数配置
登陆和注册之前,需要封装 前端参数的校验,ajax的封装 参数校验,创建公共的类 ,它是一个静态类 这样在调用的时候,直接一句话就可以了,这就是封装的好处 空字符串的校验 调用方式 EF的源码里面有这 ...
- Web.config文件中关于Cookie安全性的考量和设置
cookie的内容,如图所示: HTTP response header: Set-Cookie: <name>=<value>[; <Max-Age>=<a ...
- ACM-ICPC2018南京网络赛 AC Challenge(一维状压dp)
AC Challenge 30.04% 1000ms 128536K Dlsj is competing in a contest with n (0 < n \le 20)n(0<n ...
- SqlHelper 增删改查
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...