ميحرلا نمحرلا الله مسب Mosab2a Questions #2, #3 Pizza !: Input
ميحرلا نمحرلا الله مسب Mosab2a Questions #2, #3 Pizza !: Input
Pizza !
A Pizza chef needs to sort the pizza in the facultys restaurant to reduce the delay in his
service .
NOTE : the only move available is to flip the pizza upside down (see example)
:D http://www.youtube.com/watch?v=O04A_qKFIhA :
6 5
Input :
First line is N , which is the number of pizzas . Followed by N lines of unsorted pizza sizes
(integers) , notice that all sizes are different , no repeated values.
Required Output :
The least number of moves required to sort them .
Example :
Input :
4
8
2
1
3
Steps (just for clarification , not required in the output , but it can be a bonus ;))
Move
8
2
1
3
Output :
3
first
3
1
2
8
second
2
1
3
8
third
1
2
3
8
The Code !
Your friend challenges you to know what code he is thinking of . You know his code is binary
with n number of digits .
You are allowed to ask him n questions or less in the form of n-digit code of your choice , he
will then tell you how many digits matches between your code and his .
You will output the question , I will enter the number of matches in my code and your
question code .
Digit ..
Digit , 0 , 0000 , 0111
3 1111 , ) , (
..
NOTE : that this program is interactive , means you will ask the user and he will reply to
you as well .
Input :
First input will be the number of digits of my binary code .
Each OUTPUT will be followed by an INPUT from me with the number of correct matches
between your question code and the code in my head
:D ,
Output :
N or less questions (of your choice) , but you must CHOOSE and PROCESS the result well in
order to guess my code .The final output should be the code .
Example :
My code is 101.
, :
Input
Output
3
111
2
000
1
101
3
101