XOR machine is right now arranged with an inquiry size of k (which you can't change), and permits you to play out the accompanying sort of question: by giving the machine k unmistakable records x1,x2,… ,xk, it will output ax1⊕ax2⊕… ⊕axk.    As Little Dormi's more seasoned sibling, you might want

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Correct answer will be upvoted else downvoted.

 

The XOR machine is right now arranged with an inquiry size of k (which you can't change), and permits you to play out the accompanying sort of question: by giving the machine k unmistakable records x1,x2,… ,xk, it will output ax1⊕ax2⊕… ⊕axk. 

 

As Little Dormi's more seasoned sibling, you might want to assist him with recuperating the XOR-amount of his exhibit a1,a2,… ,a by questioning the XOR machine. 

 

Little Dormi isn't extremely understanding, so to be just about as quick as could really be expected, you should inquiry the XOR machine the base number of times to discover the XOR-amount of his cluster. Officially, let d be the base number of inquiries expected to discover the XOR-amount of any variety of length n with an inquiry size of k. Your program will be acknowledged whether you track down the right XOR-aggregate in all things considered d questions. 

 

Finally, you likewise saw that with specific setups of the machine k and upsides of n, it may not be feasible to recuperate the XOR-amount of Little Dormi's lost cluster. In case that is the situation, you should report it also. 

 

The exhibit a1,a2,… ,an is fixed before you begin questioning the XOR machine and doesn't change with the inquiries. 

 

Input 

 

The main line of input contains the integers n and k (1≤n≤500, 1≤k≤n), the length of the lost cluster and the designed inquiry size of the XOR machine. 

 

Components of the first exhibit fulfill 1≤ai≤109. 

 

It very well may be demonstrated that that in case it is feasible to recuperate the XOR total under the given limitations, it tends to be done in all things considered 500 inquiries. That is, d≤500. 

 

Subsequent to taking n and k, start cooperation. 

 

Output 

 

In case it is difficult to recuperate the XOR-amount of the exhibit, output −1 following taking n and k. Try not to start connection. 

 

In any case, when your program discovers the XOR-amount of the lost exhibit a1,a2,… ,an, report the appropriate response in the accompanying organization: "! x", where x is the XOR amount of the exhibit a1,a2,… ,an, and end your program regularly following flushing the output stream. 

 

Note that noting doesn't consider a question. 

 

Connection 

 

Each question is made in the configuration "? b", where b is a variety of precisely k unmistakable integers from 1 to n meaning the records of the components in the lost exhibit that you need to inquiry the XOR amount of. 

 

You will then, at that point, get an integer x, the XOR amount of the questioned components. It tends to be demonstrated that 0≤x≤2⋅109 will consistently be valid.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education