CF241B.Friends

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have nn friends and you want to take mm 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=3n=3 friends you can take 33 different pictures, each containing a pair of your friends.

Each of your friends has an attractiveness level which is specified by the integer number aia_{i} for the ii -th friend. You know that the attractiveness of a picture containing the ii -th and the jj -th friends is equal to the exclusive-or ( xorxor operation) of integers aia_{i} and aja_{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 10000000071000000007 (109+7)(10^{9}+7) .

输入格式

The first line of input contains two integers nn and mm — the number of friends and the number of pictures that you want to take.

Next line contains nn space-separated integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 0<=ai<=1090<=a_{i}<=10^{9} ) — the values of attractiveness of the friends.

输出格式

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
    
首页