ENIGMA-0x02 (2024) - J3 / S2 (The Magic Number)

View as PDF

Submit solution

Points: 100 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem types
Allowed languages
Blockly, C, C++, Java, Pascal, Python

The Magic Number

Totos is preparing to guess the magic number and win in the lucky game with the same name. To do this, he decided to create the following program on his computer to practice.

Initially, the program will read the magic number from the input.
Then, it will read some numbers, as many as needed, until it finds one that matches the magic number. For each number it reads, it will print to the output:

  • 1, if the number read is smaller than the magic number,
  • 2, if the number read is greater than the magic number,
  • 0, when the number read equals the magic number.
Examples
1st

Input

100
5
100

Output

1
0
Explanation of the first example:

The input contains the magic number 100 and 2 guesses, 5 and 100.
The output first prints 1 because 5 < 100, and then prints 0 because 100 = 100.

2nd

Input

10
11
9
12
10

Output

2
1
2
0
Explanation of the second example:

The input contains the magic number 10 and 4 guesses: 11, 9, 12, and 10.
The output first prints 2 because 11 > 10, then 1 because 9 < 10, followed by 2 because 12 > 10, and finally 0 because 10 = 10.

3d

Input

10
3
10
11

Output

1
0
Explanation of Example 3:

The input contains the magic number 10 and 3 guesses: 3, 10, and 11.
The output first prints 1 because 3 < 10, and then prints 0 because 10 = 10.
No further numbers are printed because the program stopped when the magic number was found.


Comments

There are no comments at the moment.