当前位置:网站首页>[cf] 803 div2 A. XOR Mixup
[cf] 803 div2 A. XOR Mixup
2022-06-30 11:36:00 【*DDL_GzmBlog】
前言
t a g : tag : tag:暴力异或
传送门 :
题意
给定一个数组 A A A,其中 n − 1 n-1 n−1个数是原数组,另一个数 n − 1 n-1 n−1个数的异或,询问给出的任意排列中,该数是什么值
思路
因为数组可以分为两部分, n − 1 n-1 n−1和 1 1 1,又因为必然存在有解
所以整个数组异或和为 0 0 0,因此随便取一个即可
Mycode
void solve(){
cin>>n;
for(int i = 1;i<=n;i ++ ) cin>>a[i];
for(int i = 1;i<=n;i++){
int res =0 ;
for(int j = 1; j <=n ; j++ ){
if(i == j) continue;
res ^= a[j];
}
if(res == a[i]){
cout<<a[i]<<endl;
return;
}
}
}
边栏推荐
猜你喜欢

CVPR 2022 | 大幅减少零样本学习所需人工标注,马普所和北邮提出富含视觉信息的类别语义嵌入...

How to analyze native crash through GDB
![[pattern recognition]](/img/b1/dcb444cbf40a43eeb7f7b233d7741a.png)
[pattern recognition]

限时预约|6 月 Apache Pulsar 中文开发者与用户组会议

这些电影中的科幻构想,已经用AI实现了

Another miserable day by kotlin grammar

A quietly rising domestic software, low-key and powerful!

1175. 质数排列

Review the writing software with characteristics

zabbix监控TCP连接个数
随机推荐
科普達人丨漫畫圖解什麼是eRDMA?
1175. prime permutation
数据库 事务
如何使用插件化机制优雅的封装你的请求hook
谁还记得「张同学」?
“\“id\“ contains an invalid value“
A theoretical defect of relative position coding transformer and Its Countermeasures
数据库 自动增长
数字化不是试出来,而是蹚出来的|行知数字中国 × 富士康史喆
Alibaba cloud database represented by polardb ranks first in the world
In depth analysis of Apache bookkeeper series: Part 4 - back pressure
How to 'gracefully' avoid MySQL login prompt information in scripts
TypeScript ReadonlyArray(只读数组类型) 详细介绍
深入解析 Apache BookKeeper 系列:第四篇—背压
Filter error in dplyr: can't transform a data frame with duplicate names
限时预约|6 月 Apache Pulsar 中文开发者与用户组会议
Summer vacation study record
Oracle netsuite helps TCM bio understand data changes and make business development more flexible
数据库连接池 druid
R语言ggplot2可视化:使用ggplot2可视化散点图、aes函数中的size参数指定数据点的大小(point size)