

Time Limit: 5 sec / Memory Limit: 1024 MB
配点 : 点
問題文
個の非負整数 が与えられます. 各 について,以下の問題を解いてください.
Alice と Bob が以下のようなゲームをします.
-
Alice が の中から 個の数を選ぶ. 選んだ数を (順不同)とおく.
-
Bob が長さ の非負整数列 を作る. ここで, は以下の条件を満たす必要がある.
- と定義する. このとき, は多重集合として と一致する.
なお, はビット単位 演算を表します.
このゲームのスコアを の値とします. Bob はスコアを最小化するように行動します. その上で Alice はスコアを最大化するように行動します. このとき,スコアはいくつになるでしょうか?
ビット単位 演算とは
非負整数 のビット単位 、 は、以下のように定義されます。
- を二進表記した際の () の位の数は、 を二進表記した際の の位の数のうち一方のみが であれば 、そうでなければ である。
一般に 個の非負整数 のビット単位 は と定義され、これは の順番によらないことが証明できます。
制約
- 入力される値はすべて整数.
入力
入力は以下の形式で標準入力から与えられる.
出力
答えを出力せよ.
入力例 1Copy
3 1 2 3
出力例 1Copy
2 6 6
の場合を考えます.
- Alice が を選んだ場合: Bob は を作り,スコアは になります.
- Alice が を選んだ場合: Bob は を作り,スコアは になります.
- Alice が を選んだ場合: Bob は を作り,スコアは になります.
よって Alice は または を選び, スコアは になります.
の場合を考えます. Alice が を選び,Bob が を作ると,スコアは になります. これは両者の最適な行動の一例であり,求める答えは です.
の場合を考えます. Alice が を選び,Bob が を作ると,スコアは になります. これは両者の最適な行動の一例であり,求める答えは です.
入力例 2Copy
5 1 1 1 1 1
出力例 2Copy
1 3 5 7 9
入力例 3Copy
5 1 2 4 8 16
出力例 3Copy
16 24 28 30 31
入力例 4Copy
20 167660508 377125547 866003430 419036363 234113368 201296307 408194538 249252693 207212853 190504619 306027011 652875643 335898069 545795899 204268068 274532279 342039277 975300308 901270584 360957186
出力例 4Copy
536870912 1610612736 2684354560 3758096384 4831838208 4831838208 4831838208 4831838208 4831838208 5100273664 5100273664 5100273664 5100273664 5100273664 5100273664 5100273664 5100273664 5100273664 5100273664 5100273664
Score : points
Problem Statement
You are given non-negative integers . For each , solve the following problem.
Alice and Bob play the following game.
-
Alice chooses numbers from . Let be the chosen numbers (in arbitrary order).
-
Bob makes a sequence of non-negative integers , which must satisfy the following conditions.
- .
- Let . Then, coincides with as a multiset.
Here, denotes bitwise .
Let the score of the game be the value of . Bob plays to minimize the score. With this in mind, Alice plays to maximize the score. What will the score be?
What is bitwise ?
The bitwise of non-negative integers and , , is defined as follows.
- When is written in binary, the -th lowest bit () is if exactly one of the -th lowest bits of and is , and otherwise.
Generally, the bitwise of non-negative integers is defined to be , which one can prove to be independent of the order of .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1Copy
3 1 2 3
Sample Output 1Copy
2 6 6
Consider the case .
- If Alice chooses : Bob makes , for the score of .
- If Alice chooses : Bob makes , for the score of .
- If Alice chooses : Bob makes , for the score of .
Thus, Alice will choose or , for the score of .
Consider the case . If Alice chooses and Bob makes , the score will be . This is an example of optimal play for both players, and the answer is .
Consider the case . If Alice chooses and Bob makes , the score will be . This is an example of optimal play for both players, and the answer is .
Sample Input 2Copy
5 1 1 1 1 1
Sample Output 2Copy
1 3 5 7 9
Sample Input 3Copy
5 1 2 4 8 16
Sample Output 3Copy
16 24 28 30 31
Sample Input 4Copy
20 167660508 377125547 866003430 419036363 234113368 201296307 408194538 249252693 207212853 190504619 306027011 652875643 335898069 545795899 204268068 274532279 342039277 975300308 901270584 360957186
Sample Output 4Copy
536870912 1610612736 2684354560 3758096384 4831838208 4831838208 4831838208 4831838208 4831838208 5100273664 5100273664 5100273664 5100273664 5100273664 5100273664 5100273664 5100273664 5100273664 5100273664 5100273664