A8676 | Friends
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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$ $(10^{9}+7)$ .
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$ $(10^{9}+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}<=10^{9}$ ) — the values of attractiveness of the friends.
Next line contains $n$ space-separated integers $a_{1},a_{2},...,a_{n}$ ( $0<=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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted