CF241B.Friends
省选/NOI-
通过率:0%
时间限制:6.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have n friends and you want to take m pictures of them. Exactly two of your friends should appear in each picture and no two pictures should contain the same pair of your friends. So if you have n = 3 friends you can take 3 different pictures, each containing a pair of your friends.
Each of your friends has an attractiveness level which is specified by the integer number a__i for the i-th friend. You know that the attractiveness of a picture containing the i-th and the j-th friends is equal to the exclusive-or (xor operation) of integers a__i and a__j.
You want to take pictures in a way that the total sum of attractiveness of your pictures is maximized. You have to calculate this value. Since the result may not fit in a 32-bit integer number, print it modulo 1000000007 (109 + 7).
你有 n 个朋友,想要为他们拍摄 m 张照片。每张照片中恰好出现两名朋友,且任意两张照片所包含的朋友对均不相同。因此,若你有 n=3 个朋友,则最多可拍摄 3 张不同的照片,每张照片包含其中一对朋友。
每位朋友都有一个吸引力值,第 i 位朋友的吸引力值为整数 ai。已知包含第 i 位和第 j 位朋友的照片的吸引力值等于整数 ai 与 aj 的按位异或(即 xor 运算)结果。
你希望以某种方式拍摄照片,使得所有照片的吸引力值之和最大化。你需要计算该最大值。由于结果可能超出 32 位整数范围,请将结果对 1000000007(即 109+7)取模后输出。
输入格式
The first line of input contains two integers n and m
— the number of friends and the number of pictures that you want to take.
Next line contains n space-separated integers _a_1, _a_2, ..., a__n (0 ≤ a__i ≤ 109) — the values of attractiveness of the friends.
输入的第一行包含两个整数 n 和 m
—— 分别表示朋友的数量和你想拍摄的照片数量。
下一行包含 n 个用空格分隔的整数 a1, a2, …, an(0≤ai≤109)—— 表示各位朋友的吸引力值。
输出格式
The only line of output should contain an integer — the optimal total sum of attractiveness of your pictures.
输出仅有一行,应包含一个整数——即你所选照片的吸引力总和的最大值。
输入输出样例
输入#1
3 1 1 2 3
输出#1
3
输入#2
3 2 1 2 3
输出#2
5
输入#3
3 3 1 2 3
输出#3
6
输入解题思路,AI测评打分。不知道怎么写?