#abc236d. D - Dance
D - Dance
Score : points
问题描述
设有编号为 的 人参加一场舞会。他们将分成 对进行舞蹈。
若第 个人和第 个人配对,其中 小于 ,则这对的 亲和度 为 。 若这 对的亲和度分别为 ,则舞会的 总乐趣值 是它们的按位异或运算结果:。
请输出在 人可以自由组合成 对的情况下,舞会的最大可能总乐趣值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
people numbered attend a ball. They will group into pairs and have a dance.
If Person and Person pair up, where is smaller than , the affinity of that pair is .
If the pairs have the affinity of , the total fun of the ball is the bitwise XOR of them: .
Print the maximum possible total fun of the ball when the people can freely group into pairs.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible total fun of the ball.
Sample Input 1
2
4 0 1
5 3
2
Sample Output 1
6
Let denote a pair of Person and Person . There are three ways for the four people to group into two pairs, as follows.
- Group into . The total fun of the ball here is .
- Group into . The total fun of the ball here is .
- Group into . The total fun of the ball here is .
Therefore, the maximum possible total fun of the ball is .
Sample Input 2
1
5
Sample Output 2
5
There will be just a pair of Person and Person , where the total fun of the ball is .
Sample Input 3
5
900606388 317329110 665451442 1045743214 260775845 726039763 57365372 741277060 944347467
369646735 642395945 599952146 86221147 523579390 591944369 911198494 695097136
138172503 571268336 111747377 595746631 934427285 840101927 757856472
655483844 580613112 445614713 607825444 252585196 725229185
827291247 105489451 58628521 1032791417 152042357
919691140 703307785 100772330 370415195
666350287 691977663 987658020
1039679956 218233643
70938785
Sample Output 3
1073289207
update @ 2024/3/10 10:13:46