

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
種類の元素があり、元素には の番号が付けられています。
元素どうしは合成させることができ、元素 と元素 を合成すると のとき元素 に、 のとき元素 に変化します。
元素 に対して元素 をこの順に合成したとき、最終的に得られる元素を求めてください。
制約
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
出力
最終的に得られる元素の番号を出力せよ。
入力例 1Copy
4 3 2 4 3 1 2 2 1 2 4
出力例 1Copy
2
-
元素 と元素 を合成すると、元素 が得られます。
-
元素 と元素 を合成すると、元素 が得られます。
-
元素 と元素 を合成すると、元素 が得られます。
-
元素 と元素 を合成すると、元素 が得られます。
したがって、出力するべき値は です。
入力例 2Copy
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
出力例 2Copy
5
入力例 3Copy
6 2 1 5 1 6 3 2 6 1 4 2 1 1 1 6 5 6 1 2 2 5
出力例 3Copy
5
Score : points
Problem Statement
There are types of elements numbered .
Elements can be combined with each other. When elements and are combined, they transform into element if , and into element if .
Starting with element , combine it with elements in this order. Find the final element obtained.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the number representing the final element obtained.
Sample Input 1Copy
4 3 2 4 3 1 2 2 1 2 4
Sample Output 1Copy
2
-
Combining element with element results in element .
-
Combining element with element results in element .
-
Combining element with element results in element .
-
Combining element with element results in element .
Therefore, the value to be printed is .
Sample Input 2Copy
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
Sample Output 2Copy
5
Sample Input 3Copy
6 2 1 5 1 6 3 2 6 1 4 2 1 1 1 6 5 6 1 2 2 5
Sample Output 3Copy
5