CodeForces742b

国科大 雁栖湖校区 研一上 课程避坑与生存指南 本文为国科大雁栖湖校区研一新生提供全面的课程避坑与生存指南,涵盖选课策略、核心课程学习技巧、校园生活攻略及心态管理。重点解析算法设计与分析、人工智能原理等硬核课程的学习方法,并分享食堂、住宿、自习室等实用生存技巧,帮助新生高效适应研究生生活。 阅读详情

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;
}
基于LabVIEW控制仪器检测与监控 --普源示波器DS1102Z-E LabVIEW 控制普源示波器 代码实现与解释 阅读详情

相关推荐

基于卷积神经网络的人脸表情识别(JAFFE篇)

1.win10/11操作系统2.python3.7以上3.tensorflow2.4以上版本(2.0其它版本需要微调)4.内存12G,显卡4G以上(没有独显倒是也能跑...)(这个可爱的妹子就是JAFFE数据集中的图片)

小林同学的计算机学习 5917

codeforces742B

Arpa’s obvious problem and Mehrdad’s terrible solution CodeForces - 742B There are some beautiful girls in Arpa’s land as mentioned before. Once Arpa came up with an obvious problem: Given an ar...

weixin_30846599的博客 162

支付逻辑漏洞的八大姿势(上篇)

学习支付漏洞,看这篇文章!!!文章来源:SecHub网络安全社区(本资料仅供学习参考,严禁使用者进行未授权渗透测试!严禁任何形式的转载!

qq_39493066的博客 1366

codeforces 742B

#include #include #include using namespace std; int a[100010]; int main() { int n,x; scanf("%d%d",&n,&x); for(int i=0;i<n;i++) { scanf("%d",&a[i]); } sort(a,a+n); int k=0,l=0; long

sinat_35121480的博客 612

Clipper库中文帮助文档

引言: 第一次接触Clipper,主要是想用来处理DXF中的图形,网上也有博友翻译过,但是可惜打不开,好像那个网站https://love2.io凉凉了,但是CSDN上也有博友分享了CHM,看着只剩3个下载币的我好无奈,一怒之下花费两天的时间将英文CHM也翻译了一遍,主要还是想在翻译的同时好好的理解Clipper,为使用打下坚实的基础。当然我也会无私的奉献出来。 简单的认识一下Clipper:...

zefllj的博客 3432

基于ENVI5.3的Landsat条带去除、辐射定标、大气校正

基于ENVI5.3的Landsat条带去除、辐射定标、大气校正坏带修复辐射定标大气校正 坏带修复 1.下载landsat_gapfill插件,放入“安装目录\Exelis\ENVI53\extensions”,重启ENVI 2. 加载拟处理文件(MTL.txt格式) 3.打开landsat_gapfill 4.选择存放位置并命名文件 5.选择处理文件 辐射定标 1.选择工具Radiometric Calibration 2.选择已修复坏带文件 3.修改参数,选择输出位置及命名文件 大气校正 1

u010198950的博客 1万+

CodeForces - 742B

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)

dreambyday 761

DeepSeek在实时计算与流处理系统中的突破性实践

对于技术决策者而言,现在正是将DeepSeek实时计算技术纳入企业架构蓝图的关键时机,那些能够率先构建实时智能能力的企业,将在数据驱动的商业竞争中赢得决定性优势。DeepSeek通过创新的流处理架构,成功将复杂事件处理(CEP)的延迟降低到亚秒级,同时保证了计算结果的精确性。DeepSeek研发的神经架构搜索(NAS)与知识蒸馏联合优化框架,可在保持模型精度的前提下,将参数量压缩至原始模型的1/100,实现边缘设备的实时AI推理。随着5G和物联网技术的普及,对实时处理能力的需求将呈指数级增长。

Programming Talk 296

Codeforces Round #383 (Div. 2) B. Arpa’s obvious problem and Mehrdad’s terrible solution

思路:a[i] ^ a[j] = x -> a[j]^x = a[i], 读入的时候找到前面有多少个对应的a[j]^x加上即可。 找的时候最大可能是2^17-1,所以数组要开的大一点。 代码: #include using namespace std; const int maxn = 1e6+5; typedef long long ll; int book[maxn], n, x

CillyB的博客 1060

【系统分析师】2025年上半年真题:案例分析-答案及详解(回忆版)

摘要: 试题一考查面向对象分析,涉及用例模型构建的四个阶段(识别参与者、合并需求、细化描述、调整模型),分析CRM系统的参与者与用例,并说明用例间的包含、扩展和泛化关系。 试题二探讨嵌入式Docker,包括容器的轻量性、可移植性及隔离性含义,10项措施与7个规范方面的对应关系,以及优化容器切换时间的三种方法(如无状态连接优化)。 试题三聚焦数据库设计,分析订单表的函数依赖与范式分解(BCNF),讨论分解后是否保持函数依赖及无损性,并针对触发器的性能缺陷提出优化方案。 试题四解析Web开发中的MVC架构与SS

数据知道的博客 6632

【系统架构设计师】十、统一建模语言UML(基本概念|UML2.0|SysML)

UML 2.0 提供了 14 种图,分别是类图、对象图、用例图、序列图、通信图(协作图)、状态图、活动图、构件图(组件图)、部署图、制品图、组合结构图、包图、交互概览图和计时图(定时图)。序列图、通信图、交互概览图和计时图均被称为交互图。 系统建模语言(SysML)是一种通用图形建模语言,用于指定,分析,设计和验证可能包括硬件,软件,信息,人员,程序和设施的复杂系统。特别是,该语言提供了图形表示,其具有用于建模系统需求,行为,结构和参数的语义基础,用于与其他工程分析模型集成。

帅次的博客 2531

CodeForces - 742B Arpa’s obvious problem and Mehrdad’s terrible solution

点击打开链接 求有多少对数相互异或后等于x。 已知 a[i]^a[j]=x   ( i so:   a[j]^x=a[i];      用一个标记数组,(桶计数)   然后每输入一个a[i].加上b[a[i]^x];   并且把b[a[i]]+1; 还有,要用ll #include #define ll long long const int maxn=10

zoro_n的博客 597

Python爬招聘网站:Selenium+ActionChains破解滑动验证码,批量采集岗位数据(新手可跑)

通过本文实战,你不仅学会了用Selenium+ActionChains破解滑动验证码,还掌握了爬虫的核心优化思路——“模拟人类行为”是突破反爬的关键。这套逻辑不仅适用于招聘网站,还能迁移到其他有滑动验证码的平台(如电商、资讯网站)。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1193

Codeforces Round #742 (Div. 2) B. MEXor Mixup

B. MEXor Mixup 原题链接 题目大意: 让你构造一个 mex 为a,xor和为b的序列 问最小的序列长度 思路: 首先因为mex为a,所以[0,a-1]都是必须选的 我们可以预处理出他的异或和sum 如果sum[ a - 1 ] = b 那么答案是 a 对于不等于的,我们都能找到一个数与其异或得到b 但是还需要考虑其mex是否不为a,也就是 b ^ sum[ a - 1 ]恰好就是 a 这时候我们就必须两个数了 如果( sum[ a - 1 ] ^ b ) = a 那么答案就是a + 2 如

遗落之辉的博客 347

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Codeforces 742B

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

黑码 466

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

Codeforces Round #742 (Div. 2)--B. MEXor Mixup

Codeforces Round #742 (Div. 2)–B. MEXor Mixup 思路 首先知道确定一个异或的数a和异或后的值x满足a^b=x,那么有且只有一个b满足该等式 数组的最小长度肯定是大于等于a的,所以先让ans=a 首先初始化将1到n的异或的值全都筛选出来保存到一个数组中 如果异或的值等于b的话,那么答案就是a,否则,将得到的值与数组中没有出现的最小值(也就是a)异或,假如得到的值等于k,那么ans=n+2,否则ans=n+1 #include <bits/

vv的博客 305

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Codeforces Round #742 (Div. 2)「B」「C」「D」妙妙场

Codeforces Round #742 (Div. 2) B. MEXor Mixup 题目描述: 输入a和b,让你造一个数组,使得这个数组内所有数异或和为b,且这个数组中未出现的最小的非负数是a 思路: 因为最小非负数是a,也就是说最少要用a-1个数,且a是不可用的 我们可以维护一个前缀异或和为tr[i],表示从0异或到i的值 如果tr[a - 1] = b,就说明用0到a-1就可以了,输出a即可 如果tr[a - 1] ^b = a,就说明要将tr[a - 1]异或上a才能变成b,但是由于a

Suryxin's blogs 184

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 solution time limit per test 1 second memory limit per test 256 megabytes input standa

Shyazhut 732

【codeforces 742B】Arpa’s obvious problem and Mehrdad’s terrible solution

time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output There are some beautiful girls in Arpa’s land as mentioned before. Once Arpa...

92

Codeforces Round #742 (Div. 2) B、C 题解

Codeforces Round 742 B. MEXor Mixup 题意 有一个数组,输入两个数a,b,a代表这个数组之外的最小非负整数,b代表这个数组的异或值,问你该数组的最小长度。 思路 首先,a保证了数组至少是由0 ~(a-1) 这些数组成,设0 ~(a-1) 的异或值为x 1.如果x==b,则该数组的最小长度为a 2.如果x!=b,且x^b!=a,此时数组之外的最小非负整数仍为a,又**因为 x^x=0, 0^b=b, abc=a(bc),**所以在原数组加上一个 **xb,xx^b=b,**此

Tr13660577247的博客 282

CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution

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 so

Sirius_han的博客 342

Arpa’s obvious problem and Mehrdad’s terrible solution codeforces problem/742/ 异或

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...

FOWng_lp的博客 277

Codeforces Round #742 (Div. 2) B,C,D,E

B. MEXor Mixup 题意: 给定2个数a,b,然后构造一个非负数组,使得这个数组满足 1.对这个数组做Mex操作,结果为a 2.对所有元素做XOR结果为b 问这个数组的长度最少是多少? 思路: 首先从2个条件出发 1.Mex(array) == a 那么代表着0 ~ a - 1这些数是必须在数组里面的,个数为a 2.XOR(array) == b 由第一个条件知道数组中肯定有0 ~ a - 1 设 x = 0 ^ 1 ^ … ^ a - 1 再设数组中还需要添加的数他们的XOR值为y 那么 x ^

weixin_54618249的博客 197

Codeforces Round #383 (Div. 2) && Codeforces 742 B (标记技巧)

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 Th

K键盘里的青春K 682

codeforces 742B Arpa's obvious problem(水)

点击打开链接 //题意:求ai^aj=x 的(i,j)&&i /两边同^ai   ->   aj=x^ai 枚举i用map统计aj=x^ai出现次数即可  //坑点ans爆int 1e5 x=3 1 2 1 2.......答案约等于1/2(1e5*1e5) 统计出来的ij的个数一一对应,则i>j个数也为k #include #include #include #in

Masamiiiiii 409

CodeForces - 742B Arpa’s obvious problem and Mehrdad’s terrible solution (位运算)

题目链接:http://codeforces.com/problemset/problem/742/B点击打开链接 B. Arpa’s obvious problem and Mehrdad’s terrible solution time limit per test 1 second memory limit per test 256 megabytes

xuejye的博客 430
上一篇: CodeForces741b
下一篇: CodeForces 148D 概率dp
NineFailure
博客等级 码龄11年 22粉丝 317原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值