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,下面代码就错了. ...
随机推荐
- [LeetCode] 188. Best Time to Buy and Sell Stock IV 买卖股票的最佳时间 IV
Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...
- .Net Core 1.1 + CentOs 7 环境配置
centos7下使用yum安装mysql5.7.10 参考:http://www.cnblogs.com/hwd-cnblogs/p/5213337.html http://www.jb51.net/ ...
- QT笔记-QlineEdit
1 QlineEdit 2 案例 构造一个用户登录界面,输入用户名密码,点击确定以后检查是否正确 (1)布局 注意事项:先拖动Label--->然后Line Edit---->按住ctrl ...
- 小程序云函数,解决接口https问题
本实例只是简单记录http请求 1,云函数如下 // 云函数入口函数 exports.main = async (event, context) => { let req = await got ...
- Linux学习-基本命令文件操作
终端 1.多个终端 连接linux的客户端可以理解为终端. 命令:tty查看终端 2.不同终端之间的通讯 [root@wyx wyx]# echo 123 > /dev/pts/1 把123发给 ...
- Apache Kafka教程
1.卡夫卡教程 今天,我们正在使用Apache Kafka Tutorial开始我们的新旅程.在这个Kafka教程中,我们将看到什么是Kafka,Apache Kafka历史以及Kafka的原因.此外 ...
- 开发板与pc之间文件传输:kermit and lrzsz
imx6开发板与pc机之间通过串口传输文件步骤: 1. 安装好kermit并可以使用 2. 交叉编译lrzsz开源软件并把可执行程序lrz lsz拷贝到开发板 2.1 下载并解压lrzsz-0.12. ...
- Python的运算符和编码
1.格式化输出 1.有两种方式: 1.1.%的方式 addr = "我家住在%s" % ("黄土高坡") 1.2.format()的方式 addr = &quo ...
- SQL——BETWEEN操作符
一.BETWEEN操作符的基本用法 BETWEEN操作符用于选取两个值范围内的值. 语法格式如下: SELECT 列名1,列名2... FROM 表名 WHERE 列名 BETWEEN 值1 AND ...
- Luogu4707 重返现世 min-max容斥、DP
传送门 kthMinMax的唯一模板? 首先你需要知道kth Min-Max定理的内容:\(kthmax(S) = \sum\limits_{T \subseteq S} (-1)^{|T| - k} ...