B. Arpa’s obvious problem and Mehrdad’s terrible solution
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

利用 x = a^b    b = x^a   由b找到a   一个循环搞定!

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
const int inf_int = 2e9;
const long long inf_ll = 2e18;
#define inf_add 0x3f3f3f3f
#define mod 1000000007
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=5e2+10;
using namespace std;
typedef  long long ll;
typedef  unsigned long long  ull;
inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;
while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')
fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,
rx=getchar();return ra*fh;}
//#pragma comment(linker, "/STACK:102400000,102400000")
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}ll n,x,t1;
ll a[1000005];int main()
{ios::sync_with_stdio(false); ll ct = 0;cin >> n >> x;for(int i=1;i<=n;i++){cin >> t1;ll t = t1^x;ct += a[t];a[t1]++;}cout << ct <<endl;return 0;
}

Codeforces 742B B. Arpa’s obvious problem and Mehrdad’s terrible solution相关推荐

  1. Codeforces 742B Arpa’s obvious problem and Mehrdad’s terrible solution

    http://codeforces.com/contest/742/problem/B B. Arpa's obvious problem and Mehrdad's terrible solutio ...

  2. CF 742 B-Arpa’s obvious problem and Mehrdad’s terrible solution

    传送门 : CF 742B 题解 异或逆运算 AC code: /*adrui's submission Language : C++ Result : Accepted Lover : zyy Fa ...

  3. Codeforces 741 D - Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths

    D - Arpa's letter-marked tree and Mehrdad's Dokhtar-kosh paths 思路: 树上启发式合并 从根节点出发到每个位置的每个字符的奇偶性记为每个位 ...

  4. 【Codeforces 741 B. Arpa's weak amphitheater and Mehrdad's 】+ 并查集 + 01背包

    B. Arpa's weak amphitheater and Mehrdad's valuable Hoses time limit per test 1 second memory limit p ...

  5. 【codeforces 742A】Arpa’s hard exam and Mehrdad’s naive cheat

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. Codeforces 742 C Arpa's loud Owf and Mehrdad's evil plan

    题目地址:http://codeforces.com/contest/742/problem/C 题意:我看了好多别人的博客的对于题意的理解,结合他们的代码我认为这道题的意思应该是每个数要都能经过t步 ...

  7. Codeforces Round #383 (Div. 2) D. Arpa's weak amphitheater and Mehrdad's valuable Hoses —— DP(01背包)

    题目链接:http://codeforces.com/contest/742/problem/D D. Arpa's weak amphitheater and Mehrdad's valuable ...

  8. CodeForces - 742B

    There are some beautiful girls in Arpa's land as mentioned before. Once Arpa came up with an obvious ...

  9. Codeforces 798C:Mike and gcd problem

    Codeforces 798C:Mike and gcd problem 题目链接:http://codeforces.com/contest/798/problem/C 题目大意:给出一个大小为$n ...

最新文章

  1. sklearn数据处理_one_hot
  2. idea中配置xml不自动提示解决方案
  3. python练习---模拟sql
  4. 007 Android之Broadcast Receiver
  5. android 简单实现圆角,Android 实现圆角图片的简单实例
  6. timer控件的使用
  7. tomcat的jdbc连接池PoolExhaustedException 1
  8. Kaldi AMI数据集脚本学习1----cmd.sh和path.sh
  9. 灵活运用用第3方软件把“SWF”变回“FLA”
  10. 两相四线步进电机的驱动
  11. 【Heydrones】飞手百科第一篇:一定要看的无人机原理总结
  12. 测试开发(社招)面经:度小满
  13. R 运行中文文件使乱码的解决方案(案例示例)
  14. c语言各种输出错误提示,C语言错误处理-输出错误信息
  15. 计算机软件可以授予专利权吗,软件产品能申请专利吗?
  16. 盒子装载图片时出现的盒子比图片实际偏高的问题
  17. 如何截取视频中的一部分制作成GIF动态图
  18. 3、TextBox 控件
  19. 使用python计算复利
  20. B2B,B2C和C2C

热门文章

  1. iOS系统自带的字体名称集合
  2. 计算机用电安全知识,计算机机房用电安全制度
  3. Calendar 获取当天开始和结束时间
  4. python做并行计算_python做并行计算可以吗
  5. css——pre标签
  6. 2019运动蓝牙耳机排行榜,运动达人首选的耳机
  7. pandas数据加载与存储
  8. 最详细的语义分割---01如何读取数据集?
  9. 如何将doc格式转换成pdf格式的文件
  10. IC-14W网络IC卡读写器_银河麒麟桌面操作系统V10适配测试报告