No.632 Fill-in-the-Blank Kadomatsu Sequence
Definition
It is said that a sequence $v = (a_1,a_2,a_3)$ of three natural numbers, $v$, is a Kadomatsu sequence when it satisfies the following conditions.
- $a_1,a_2,a_3$ are all distinct
- Among the three elements, $a_2$ is the largest or the smallest
Problem Statement
One day, Yukikoji found cards with the characters "?", "2", and "3" written on them, placed in a row on a table.
Yukikoji has cards with the characters "1" and "4" written on them,
and plans to turn the sequence of numbers on the table into a Kadomatsu sequence by replacing the "?" on the table with one of these cards.
Which of the cards "1" and "4" can replace the "?"?
Input
$c_1$ $c_2$ $c_3$
Three space-separated characters are given from standard input.
Each of the three characters is one of '2', '3', or '?'.
No character is given more than once.
That is, you do not need to consider inputs such as "2 ? ?", "2 3 3", or "4 2 ?".
This input means that the cards are arranged on the table in the order $c_1$ $c_2$ $c_3$.
Output
If the card that should replace the "?" is "1", output '1'; if it is "4", output '4'.
If either "1" or "4" works, output '14'.
Print a newline at the end.
Sample
Sample 1
Input
? 2 3
Output
4
Replacing '?' with '4' gives $(4,2,3)$, which makes a Kadomatsu sequence.
Sample 2
Input
3 ? 2
Output
14
Replacing '?' with '1' gives $(3,1,2)$, which makes a Kadomatsu sequence.
In addition, replacing '?' with '4' gives $(3,4,2)$, which also makes a Kadomatsu sequence, so you must output 14.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。