#CCBCHHAI0000009. Nhập lựa chọn 1, 2, 3 (Accept Choice 1 2 or 3)
Nhập lựa chọn 1, 2, 3 (Accept Choice 1 2 or 3)
Accept Choice 1 2 or 3
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Read integer choice codes until the first one equal to 1, 2, or 3. Ignore invalid codes and print the first accepted code.
Input
An integer sequence whose last value is in {1,2,3} and earlier values are not.
Output
Print one integer from {1,2,3}.
Subtasks
- Subtask 1 (20%): At most 5 values; each value has absolute value at most 10.
- Subtask 2 (30%): At most 100 values; each value has absolute value at most 1000.
- Subtask 3 (50%): At most 100001 values; each value has absolute value at most 1000000.
Examples
Example 1
Input
8 -1 3
Output
3
Explanation
Eight and -1 are invalid; 3 is the first valid choice.
Example 2
Input
1
Output
1
Explanation
The first choice is valid and no further read is needed.