Question: give a code in java ( there should not be plagiarism ) B . Nuts and Bolts 2 seconds, 2 5 6 megabytes Steven has
give a code in javathere should not be plagiarism
B Nuts and Bolts
seconds, megabytes
Steven has nuts and bolts. All nuts have different sizes from to and all bolts have different sizes from to
The operation Steven can perform is to try to compare one of the nuts with one of the bolts. As a result he will learn if the size of nut is greater, the size of bolt is greater or these nut and bolt match. He wants to find the matching nut for every bolt.
You must help Steven to do the plan, using no more than operations.
Interaction
This is an interactive problem. Your program should communicate with the jury's program, using standard input and output for that.
At the beginning your program receives the integer the number of nuts and bolts.
After that you can make no more than queries. To do a query, output the character and then numbers i and
the number of nut and the number of bolt that Steven will try to compare.
As a result, you receive one of the three characters:
If the size of the th nut is less than the size of the th bolt,
if the th nut and the th bolt match,
if the size of the th nut is greater than the size of the th bolt.
As soon as you can say which nut matches which bolt, output the character and then distinct integers where is the number of bolt which matches the nut with the number After that your program must terminate
Please note that each your message must end with a line break. Also after
outputting each message your program must flush the stream buffer, so
that the outputted information could reach jury's program: for instance, this
can be done by calling "fflush stdout or "cout. flush in
C "System.out. Plush in Java, "Console. Out. Flush
in CH "Elush output in Pascal, sys stdout. Flush in
Python.
Emply lines in the sample are given only for convenience, to make it clear
in which order the messages are written. When solving the problem you
must not output empty lines and jury's program won't output empty lines
too.
for sample inputoutput please refer to the images attached.
give a code in javaplease there should not be any plagiarism
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
