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-交互题的更多相关文章

  1. 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 ...

  2. Educational Codeforces Round 71 (Rated for Div. 2)E. XOR Guessing

    一道容斥题 如果直接做就是找到所有出现过递减的不同排列,当时硬钢到自闭,然后在凯妹毁人不倦的教导下想到可以容斥做,就是:所有的排列设为a,只考虑第一个非递减设为b,第二个非递减设为c+两个都非递减的情 ...

  3. 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  ...

  4. Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块

    Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ​ ...

  5. [暴力] 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 ...

  6. [贪心,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 ...

  7. Educational Codeforces Round 71 (Rated for Div. 2)

    传送门 A.There Are Two Types Of Burgers 签到. B.Square Filling 签到 C.Gas Pipeline 每个位置只有"高.低"两种状 ...

  8. Educational Codeforces Round 71 (Rated for Div. 2) Solution

    A. There Are Two Types Of Burgers 题意: 给一些面包,鸡肉,牛肉,你可以做成鸡肉汉堡或者牛肉汉堡并卖掉 一个鸡肉汉堡需要两个面包和一个鸡肉,牛肉汉堡需要两个面包和一个 ...

  9. Remainder Problem(分块) Educational Codeforces Round 71 (Rated for Div. 2)

    引用:https://blog.csdn.net/qq_41879343/article/details/100565031 下面代码写错了,注意要上面这种.查:2  800  0,下面代码就错了. ...

随机推荐

  1. [LeetCode] 258. Add Digits 加数字

    Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...

  2. [LeetCode] 723. Candy Crush 糖果粉碎

    This question is about implementing a basic elimination algorithm for Candy Crush. Given a 2D intege ...

  3. mybatis对实体的引用必须以 ';' 分隔符结尾

    今天在使用 generate 时(问题起源),由于扫描了mysql所有库下的user表,因此添加参数 nullCatalogMeansCurrent=true 添加改参数解决的原因 查看 但是添加后出 ...

  4. win10锁住鼠标和键盘操作。

    以前做的一个winform自动更新程序没考虑到程序在更新过程中禁止操作被更新程序.现在加上了更新过程中锁住鼠标和大部分键盘. 碰到问题:用系统api -- BlockInput(true)锁住屏幕无效 ...

  5. 「LOJ2091」「ZJOI2016」小星星 容斥+DP

    题目描述 小 Y 是一个心灵手巧的女孩子,她喜欢手工制作一些小饰品.她有\(n\)颗小星星,用 \(m\)条彩色的细线串了起来,每条细线连着两颗小星星.有一天她发现,她的饰品被破坏了,很多细线都被拆掉 ...

  6. [转帖]DCEP究竟是什么?

    DCEP究竟是什么? https://www.cnblogs.com/kaixin2018/p/11795534.html DCEP (Digital Currency Electronic Paym ...

  7. java笔记4

    private关键字 1.是一个权限修饰符.       2.用于修饰成员       3.被私有化的成员只能在本类中有效 常用之一: -将成员变量私有化,对外提供对应的set,get方法对其进行访问 ...

  8. Django框架之DRF 基于mixins来封装的视图

    基础视图 示例环境搭建:新建一个Django项目,连接Mysql数据库,配置路由.视图函数.序列化单独创建py文件 # 配置路由 from django.conf.urls import url fr ...

  9. DjangoRestFramework学习二之序列化组件、视图组件

    本节目录 一 序列化组件 二 视图组件 三 xxx 四 xxx 五 xxx 六 xxx 七 xxx 八 xxx 一 序列化组件 首先按照restful规范咱们创建一些api接口,按照下面这些形式写吧: ...

  10. Linux忘记root密码操作方法

    此方法为:进入单用户模式,直接修改新密码覆盖掉以前的root密码. 操作步骤: 1.进入单用户模式 2.修改root密码 1.进入单用户方法: 1)启动Linux时,通过按上下键(其他键也可以)让Li ...