#abc236f. F - Spices
F - Spices
Score : points
问题描述
商店 supaisu-ya 销售 种香料:香料 、香料 、……、香料 。每种香料库存一包。对于每个 ,香料 的价格为 日元。Takahashi 可以购买这些香料中的任意一种。
他计划在回家后选择并混合所购买的一种或多种香料来制作咖喱。
如果混合了 种香料,即香料 、香料 、……、香料 ,那么得到的咖喱辣度为 ,其中 表示按位异或运算。
根据回家后的感受,Takahashi 想决定咖喱的辣度。现在,他将购买一组香料,使得他能制作出从 到 的任何辣度的咖喱。请输出 Takahashi 最少需要支付的金额。
以上为通义千问 qwen-max 翻译,仅供参考。
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 1
2
4 5 3
Sample Output 1
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 2
4
9 7 9 7 10 4 3 9 4 8 10 5 6 3 8
Sample Output 2
15
update @ 2024/3/10 10:14:23