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

E. XOR Guessing

Interactive title.

Because this number at most 14 0 to 13, so we can first deal with the back seven, and then treated seven behind.

Because of the nature or different, and if a number 0 or isobutyl, it is equivalent to itself.

Therefore, we first exclusive or from 1 to 100 so the back to 7-13 are 0, so that the latter can result 7 calculated.

Similarly you can then find the front seven.

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <iostream>
#include <string>
#include <map>
#define inf 0x3f3f3f3f
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
const int maxn = 3e5 + 10;
typedef long long ll;

int main() {
    ll ans = 0;
    printf("?");
    for (int i = 1; i <= 100; i++)    printf(" %d", i);
    printf("\n");
    fflush(stdout);
    ll num;
    scanf("%lld", &num);
    for(int i=7;i<14;i++) ans += ((num >> i) & 1) << i;
    printf("?");
    i =intfor (1; i <= 100; i++) printf(" %d", i << 7);
    printf("\n");
    fflush(stdout);
    scanf("%lld", &num);
    for (int i = 0; i < 7; i++) ans += ((num >> i) & 1) << i;
    printf("! %lld\n", ans);
    return 0;
}
View Code

 

Guess you like

Origin www.cnblogs.com/EchoZQN/p/11407253.html