There are some beautiful girls in Arpa’s land as mentioned before.

Once Arpa came up with an obvious problem:

Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that , where is bitwise xor operation (see notes for explanation).

Immediately, Mehrdad discovered a terrible solution that nobody trusted. Now Arpa needs your help to implement the solution to that problem.

Input
First line contains two integers n and x (1 ≤ n ≤ 105, 0 ≤ x ≤ 105) — the number of elements in the array and the integer x.

Second line contains n integers a1, a2, …, an (1 ≤ ai ≤ 105) — the elements of the array.

Output
Print a single integer: the answer to the problem.

Examples
input
2 3
1 2
output
1
input
6 1
5 1 2 3 4 1
output
2
Note
In the first sample there is only one pair of i = 1 and j = 2. so the answer is 1.

In the second sample the only two pairs are i = 3, j = 4 (since ) and i = 1, j = 5 (since ).

A bitwise xor takes two bit integers of equal length and performs the logical xor operation on each pair of corresponding bits. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1. You can read more about bitwise xor operation here: https://en.wikipedia.org/wiki/Bitwise_operation#XOR.

异或的逆运算还是异或
坑是特判0的情况

#include<iostream>
#include<cmath>
using namespace std;
int tu[1000001];
int yingshe[1000001];
int main()
{
#define int long long int n, x;cin >> n >> x;for (int a = 1;a <= n;a++){scanf("%I64d", &tu[a]);yingshe[tu[a]] ++;}int jieguo = 0;for (int a = 1;a <= n;a++){if ((tu[a] ^ x) > 100000)continue;if (x == 0){jieguo += (yingshe[x^tu[a]]-1);continue;}if (yingshe[x^tu[a]]){jieguo +=yingshe[x^tu[a]];}}cout << jieguo / 2 << endl;return 0;
}

CodeForces742b相关推荐

最新文章

  1. 解决oracle主键问题,解决renren-security使用oracle主键问题
  2. html属性可以用来定义内联样式,18年6月考试《网页设计与制作》期末大作业.doc...
  3. React Native集成Redux框架讲解与应用
  4. 防止重复提交js jquery ajax
  5. java 等分切割图片_java 将list按指定大小等分,最后多余的单独一份
  6. 2-4:C++快速入门之函数重载
  7. Matlab Tricks(二十五)—— plot 属性
  8. tensorflow之线性回归
  9. (转)马克•柯霍德斯:一位王牌大空头的传奇人生
  10. Revit2020下载Revit2020安装教程
  11. 故宫元宵灯会票务系统崩溃背后:年游客达1700万人
  12. php 快手视频,初学PHP:简单的快手和抖音短视频解析
  13. mov转换成mp4,详细步骤
  14. 电科 | 电子器件微纳米加工技术
  15. 隐藏OEM分区的解决办法和推荐的清理磁盘的方法
  16. 学生信息管理系统V2.0
  17. Win8快捷键收集大汇总
  18. C源码:通过IP地址查找主机名 findip.c
  19. Revit二次开发入门相关安装和配置
  20. 【机器学习】手写识别系统

热门文章

  1. 1588 数字游戏(LOJ10166) 暴力0分 需要记录中间数据的数位DP
  2. 亿级高并发电商项目-- 实战篇 --万达商城项目 八(安装FastDFS、安装Nginx、文件服务模块、文件上传功能、商品功能与秒杀商品等功能)
  3. 水资源检测数据传输规约解析(SZY206-2016)
  4. soup java_Soup协议-即普通post请求,内容域xml
  5. 记录批量将smiles转化为mol,并将分子图保存为png代码
  6. Ubuntu学习系列——添加源
  7. 锐捷——接口光电切换配置
  8. ORCL-主线2-PLSQL学习
  9. 23 种设计模式的易懂解释
  10. 曾经有6.5亿用户 Skype为什么还是没挺住