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,下面代码就错了. ...
随机推荐
- python json dumps datetime类型报错
# -*- coding: utf-8 -*- import json from datetime import date, datetime class MyEncoder(json.JSONEnc ...
- nrm -- npm镜像源管理
nrm nrm(npm registry manager )是npm的镜像源管理工具,有时候国外资源太慢,使用这个就可以快速地在 npm 源间切换 安装nrm 在命令行执行命令,npm install ...
- Java设置文件权限
今天遇到一个问题: java写的API,ppt转图片生成的目录及文件 在使用php调用API完成后,再使用php进行删除时,遇到了删除失败的问题(php删除的部分 查看) 部署的环境是Ubuntu ...
- USACO19DEC题解
Bronze A Cow Gymnastics 题目:https://www.luogu.com.cn/problem/P5831 题解:用数组存一下出现位置,O(n^2)枚举一下就好. 代码: #i ...
- Linux定时自动备份oracle数据库
1.在服务器创建备份目录,并赋予权限mkdir -p /backup/P_DATA #新建shell脚本存放路径mkdir -p /backup/P_DB_BACK #新建Oracle数据库备份目录 ...
- C++ 读写 Excel 文件
//Microsoft Visual Studio 2015 Enterprise #include <fstream> #include <string> #include ...
- linux系统调整磁盘分区
xfs分区格式调整分区大小 调整前备份: mkdir /tmp/home cp -r /home/* /tmp/home/ umount /home 卸载时报错有占用 fuser -m -v -i - ...
- windows10环境下的RabbitMQ使用_笔记
使用默认账号:guest/guest登录http://localhost:15672/#/进去,添加一个新用户(Administrator权限),并设置其Permission 新建两个控制台程序 安装 ...
- java 获取手机归属地,引起net.UnknownHostException错误
这个问题是请求,重定向了,跟入源码.修改了地址,变成302 Connection connect = Jsoup.connect(url); connect.header("Host&quo ...
- 解决COM组件在WPF设计器中命名空间不存在XXX的问题(附带如何在WPF中使用APlayer引擎)
总结起来就是:设计器的版本要跟外部引用的库版本一致,否则XAML设计器就会显示不出来. 例如你的程序是X64的,但是引用的COM组件是32位的,就会显示不出来.这里的建议是:编译一个32位的COM中间 ...