题意:https://codeforc.es/contest/1207/problem/E
答案guessing(0~2^14-1)
有两次机会,内次必须输出不同的100个数,每次系统会随机挑一个你给的数,告诉你答案XOR这个数的值。
问你这个答案是多少。
思路:
先输出100个前7位位0的数,再输出100个后7位为0的数,计算即可。
1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include <cstdio>//sprintf islower isupper 3 #include <cstdlib>//malloc exit strcat itoa system("cls") 4 #include <iostream>//pair 5 #include <fstream>//freopen("C:\\Users\\13606\\Desktop\\草稿.txt","r",stdin); 6 #include <bitset> 7 //#include <map> 8 //#include<unordered_map> 9 #include <vector> 10 #include <stack> 11 #include <set> 12 #include <string.h>//strstr substr 13 #include <string> 14 #include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9; 15 #include <cmath> 16 #include <deque> 17 #include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less 18 #include <vector>//emplace_back 19 //#include <math.h> 20 //#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor 21 #include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare) 22 using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation 23 #define fo(a,b,c) for(register int a=b;a<=c;++a) 24 #define fr(a,b,c) for(register int a=b;a>=c;--a) 25 #define mem(a,b) memset(a,b,sizeof(a)) 26 #define pr printf 27 #define sc scanf 28 #define ls rt<<1 29 #define rs rt<<1|1 30 typedef long long ll; 31 void swapp(int &a,int &b); 32 double fabss(double a); 33 int maxx(int a,int b); 34 int minn(int a,int b); 35 int Del_bit_1(int n); 36 int lowbit(int n); 37 int abss(int a); 38 //const long long INF=(1LL<<60); 39 const double E=2.718281828; 40 const double PI=acos(-1.0); 41 const int inf=(1<<30); 42 const double ESP=1e-9; 43 const int mod=(int)1e9+7; 44 const int N=(int)1e6+10; 45 46 int main() 47 { 48 int t,ans=0; 49 cout<<(1<<7)<<endl; 50 51 pr("? "); 52 for(int i=1;i<=100;++i) 53 pr("%d%c",i,i==100?'\n':' '); 54 fflush(stdout); 55 56 sc("%d",&t); 57 for(int i=13;i>=7;--i) 58 ans+=((t>>i)&1)<<i; 59 60 pr("? "); 61 for(int i=1;i<=100;++i) 62 pr("%d%c",i<<7,i==100?'\n':' '); 63 fflush(stdout); 64 65 sc("%d",&t); 66 for(int i=6;i>=0;--i) 67 ans+=((t>>i)&1)<<i; 68 pr("! %d\n",ans); 69 return 0; 70 } 71 72 /**************************************************************************************/ 73 74 int maxx(int a,int b) 75 { 76 return a>b?a:b; 77 } 78 79 void swapp(int &a,int &b) 80 { 81 a^=b^=a^=b; 82 } 83 84 int lowbit(int n) 85 { 86 return n&(-n); 87 } 88 89 int Del_bit_1(int n) 90 { 91 return n&(n-1); 92 } 93 94 int abss(int a) 95 { 96 return a>0?a:-a; 97 } 98 99 double fabss(double a) 100 { 101 return a>0?a:-a; 102 } 103 104 int minn(int a,int b) 105 { 106 return a<b?a:b; 107 }