1637.Friends

Time Limit: 1s Memory Limit: 256MB

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 ai 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 ai and aj.
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).
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 ai 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 ai and aj.
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).
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 ai 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 ai and aj.
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).
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 ai 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 ai and aj.
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).

Input Format(From the terminal/stdin)

Input

The first line of input contains two integers n and m 1637_1.png - the number of friends and the number of pictures that you want to take.

Next line contains n space-separated integers a1,a2,...,an (0 \le ai \le 109) - the values of attractiveness of the friends.

Output Format(To the terminal/stdout)

Output

The only line of output should contain an integer - the optimal total sum of attractiveness of your pictures.

Sample Input 1

Copy
3 1
1 2 3
 · \n
 · · \n

Sample Output 1

Copy
3
 \n

Sample Input 2

Copy
3 2
1 2 3
 · \n
 · · \n

Sample Output 2

Copy
5
 \n

Sample Input 3

Copy
3 3
1 2 3
 · \n
 · · \n

Sample Output 3

Copy
6
 \n

Submit

请先 登录

© 2025 FAQs