

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
スパイス屋には、スパイス 、スパイス 、 、スパイス の 種類のスパイスがそれぞれ 個ずつ売られています。 について、スパイス の値段は 円です。 高橋君はそれらを好きなだけ買うことができます。
高橋君は帰宅後、買ったスパイスのうち つ以上を選び、それらを組み合わせてカレーを作る予定です。
高橋君がスパイス 、スパイス 、、スパイス の 個のスパイスを組み合わせると、完成するカレーの辛さは になります。
ここで、 はビットごとの排他的論理和を表します。
高橋君は、作るカレーの辛さを帰宅後の気分で決めたいので、とりあえず 以上 以下の任意の整数の辛さのカレーを作れるように、購入するスパイスの組み合わせを決定します。高橋君が支払う金額としてあり得る最小値を出力してください。
制約
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
出力
高橋君が支払う金額としてあり得る最小値を出力せよ。
入力例 1Copy
2 4 5 3
出力例 1Copy
7
高橋君がスパイス とスパイス を買うと、下記の通り、 以上 以下の任意の整数の辛さのカレーを作ることができます。
- 辛さ のカレーを作るには、スパイス のみを使い、
- 辛さ のカレーを作るには、スパイス とスパイス を組み合わせ、
- 辛さ のカレーを作るには、スパイス のみを使えば良いです。
このとき高橋君が支払う金額は 円であり、これが高橋君が支払う金額としてあり得る最小値です。
入力例 2Copy
4 9 7 9 7 10 4 3 9 4 8 10 5 6 3 8
出力例 2Copy
15
Score : points
Problem Statement
The shop supaisu-ya sells kinds of spices: Spice , Spice , , Spice . One pack of each spice is in stock. For each , Spice costs yen. Takahashi can buy any of these spices.
He plans to make curry after getting home by choosing one or more of the bought spices and mixing them.
If spices, Spice , Spice , , Spice , are mixed, the hotness of the resulting curry is , where denotes the bitwise XOR.
Takahashi wants to decide the hotness of the curry based on his feeling after getting home. For now, he will buy a set of spices that allows him to make curry of any hotness from through . Print the minimum possible amount of money Takahashi pays.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the minimum possible amount of money Takahashi pays.
Sample Input 1Copy
2 4 5 3
Sample Output 1Copy
7
If Takahashi buys Spice and , he can make curry of any hotness from through , as follows.
- To make curry of hotness , use just Spice .
- To make curry of hotness , mix Spice and Spice .
- To make curry of hotness , use just Spice .
Here, Takahashi pays yen, which is the minimum possible amount he pays.
Sample Input 2Copy
4 9 7 9 7 10 4 3 9 4 8 10 5 6 3 8
Sample Output 2Copy
15