Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题
Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题

【Problem Description】
总共两次询问,每次询问给出\(100\)个不同的数,评测系统对于每次询问,随机从\(100\)个数中选择一个数\(a\),返回\(x\oplus a\)。让你通过两次返回的值猜出\(x\)值是多少。要求两次询问的\(200\)个数互不相同,且题目保证\(x\)值固定不变。
【Solution】
题目要求所有询问数据,即\(x\)的值在\([0,2^{14}-1]\)范围内,且只能询问两次,根据异或的性质,\(0\)异或任何数都不改变。所以可以分两次得到答案,即第一次先确定\(x\)二进制中的高\(7\)位,也就是第一次询问时,所有询问的数的高\(7\)位全为\(0\),这样保证评测系统选任何数异或后返回的值的高\(7\)位一定与\(x\)的高\(7\)位相同,同理,第二次只要保证所有询问的数的低\(7\)位全为\(0\),最终将两次得到的值合并即可。
【Code】
/*
* @Author: Simon
* @Date: 2019-08-27 20:36:36
* @Last Modified by: Simon
* @Last Modified time: 2019-08-27 21:57:17
*/
#include<bits/stdc++.h>
using namespace std;
typedef int Int;
#define int long long
#define INF 0x3f3f3f3f
#define maxn 200005
int a[maxn];
Int main(){
#ifndef ONLINE_JUDGE
//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
cout<<"? ";
for(int i=1;i<=100;i++) cout<<i<<" "; //第一次保证高7位为0
cout<<endl;
int ans;cin>>ans;
ans|=127; //低7位全置1
cout<<"? ";
for(int i=1;i<=100;i++) cout<<(i<<7)<<' ';//第二次保证低7为0
cout<<endl;
int tmp;cin>>tmp;
(ans&=(tmp|(127<<7))); //合并第二次的低7位
cout<<"! "<<ans<<endl;
#ifndef ONLINE_JUDGE
cout<<endl;system("pause");
#endif
return 0;
}
Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题的更多相关文章
- Educational Codeforces Round 71 (Rated for Div. 2) E XOR Guessing (二进制分组,交互)
E. XOR Guessing time limit per test1 second memory limit per test256 megabytes inputstandard input o ...
- Educational Codeforces Round 71 (Rated for Div. 2)E. XOR Guessing
一道容斥题 如果直接做就是找到所有出现过递减的不同排列,当时硬钢到自闭,然后在凯妹毁人不倦的教导下想到可以容斥做,就是:所有的排列设为a,只考虑第一个非递减设为b,第二个非递减设为c+两个都非递减的情 ...
- Educational Codeforces Round 65 (Rated for Div. 2)(ACD)B是交互题,不怎么会
A. Telephone Number A telephone number is a sequence of exactly 11 digits, where the first digit is ...
- Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块
Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ...
- [暴力] Educational Codeforces Round 71 (Rated for Div. 2) B. Square Filling (1207B)
题目:http://codeforces.com/contest/1207/problem/B B. Square Filling time limit per test 1 second mem ...
- [贪心,dp] Educational Codeforces Round 71 (Rated for Div. 2) C. Gas Pipeline (1207C)
题目:http://codeforces.com/contest/1207/problem/C C. Gas Pipeline time limit per test 2 seconds memo ...
- Educational Codeforces Round 71 (Rated for Div. 2)
传送门 A.There Are Two Types Of Burgers 签到. B.Square Filling 签到 C.Gas Pipeline 每个位置只有"高.低"两种状 ...
- Educational Codeforces Round 71 (Rated for Div. 2) Solution
A. There Are Two Types Of Burgers 题意: 给一些面包,鸡肉,牛肉,你可以做成鸡肉汉堡或者牛肉汉堡并卖掉 一个鸡肉汉堡需要两个面包和一个鸡肉,牛肉汉堡需要两个面包和一个 ...
- Remainder Problem(分块) Educational Codeforces Round 71 (Rated for Div. 2)
引用:https://blog.csdn.net/qq_41879343/article/details/100565031 下面代码写错了,注意要上面这种.查:2 800 0,下面代码就错了. ...
随机推荐
- 【视频开发】RTSP SERVER(基于live555)详细设计
/* *本文基于LIVE555的嵌入式的RTSP流媒体服务器一个设计文档,个中细节现剖于此,有需者可参考指正,同时也方便后期自己查阅.(本版本是基于2011年的live555) 作者:llf_17@q ...
- 【神经网络与深度学习】【计算机视觉】Faster R-CNN
Faster R-CNN Fast-RCNN基本实现端对端(除了proposal阶段外),下一步自然就是要把proposal阶段也用CNN实现(放到GPU上).这就出现了Faster-RCNN,一个完 ...
- VueJS中学习使用Vuex详解
转载自:https://segmentfault.com/a/1190000015782272,做了部分修改(这里建议不要用所谓的getters,一来多次一举,二来模块化时会产生很不协调的用法) 在S ...
- 15 SpringMVC的入门案例
1.入门程序的需求 2.搭建开发环境 <1>Create New Project <2>创建一个webapps <3>设置maven路径和解决maven项目创建过慢 ...
- 用外部按钮打开DATETIMEPICKER下拉日期选择窗口
https://www.cnblogs.com/gaodu2003/archive/2009/08/10/1543115.html 方法一: SendMessage(DateTimePicker1.H ...
- AX 2009中Set运用
Set运行: 例子: Set m_set = new Set(Types::String); m_set.add("AAA"); m_set.add("BBB" ...
- [UOJ #140]【UER #4】被粉碎的数字
题目大意:定义$f(x)$为数字$x$每一位数字的和,求$\sum\limits_{i=1}^R[f(x)=f(kx)]$.$R\leqslant10^{18},k\leqslant10^3$ 题解: ...
- [高清·非影印] 深度学习入门:基于Python的理论与实现 + 源代码
------ 郑重声明 --------- 资源来自网络,纯粹共享交流, 如果喜欢,请您务必支持正版!! --------------------------------------------- 下 ...
- (三) Docker 常用操作与CentOS7 防火墙命令
参考并感谢 Docker 常用命令 https://docs.docker.com/engine/reference/commandline/docker/ Docker 登录docker账户 doc ...
- ADO.NET 五(DataAdapter 与 DataSet)
在执行对表中数据的查询时还能将数据保存到 DataSet 中,但需要借助 DataAdapter 类来实现. 在实际应用中,DataAdapter 与 DataSet 是在查询操作中使用最多的类. 此 ...