E - Red Scarf


Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 500500 points

Problem Statement

There are NN Snuke Cats numbered 1,2,…,N1,2,…,N, where NN is even.

Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.

Recently, they learned the operation called xor (exclusive OR).

What is xor?

They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.

We know that the xor calculated by Snuke Cat ii, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat ii is aiai. Using this information, restore the integer written on the scarf of each Snuke Cat.

Constraints

  • All values in input are integers.
  • 2≤N≤2000002≤N≤200000
  • NN is even.
  • 0≤ai≤1090≤ai≤109
  • There exists a combination of integers on the scarfs that is consistent with the given information.

Input

Input is given from Standard Input in the following format:

NN
a1a1 a2a2 …… aNaN

Output

Print a line containing NN integers separated with space.

The ii-th of the integers from the left should represent the integer written on the scarf of Snuke Cat ii.

If there are multiple possible solutions, you may print any of them.


Sample Input 1 Copy

Copy
4
20 11 9 24

Sample Output 1 Copy

Copy
26 5 7 22

  • 5 xor 7 xor 22=205 xor 7 xor 22=20
  • 26 xor 7 xor 22=1126 xor 7 xor 22=11
  • 26 xor 5 xor 22=926 xor 5 xor 22=9
  • 26 xor 5 xor 7=2426 xor 5 xor 7=24

Thus, this output is consistent with the given information.

题意:输入一个n,然后输入n个数字,然后请输出n个数字,让他们的数字XOR的值能组成原来的数组

解题思路:其实这道题利用到了同一个数XOR偶数次等于0,这个原理,根据XOR的原理,位相同为0,不同为1,我们可以将开始输入的n个数XOR起来,然后输出的时候分别再和输入的元素XOR,就能得到新的元素。

代码如下:

#include<cstdio>
#include<iostream>
#include<cstring>
#define maxn 200005
int a[maxn];
using namespace std;
int main(void)
{int n;scanf("%d",&n);int sum=0;for(int i=0;i<n;++i){scanf("%d",&a[i]);sum^=a[i];//n个数XOR和}for(int i=0;i<n-1;++i){printf("%d ",sum^a[i]);//消去a[i]}printf("%d\n",sum^a[n-1]);return 0;
}

AtCoder Beginner Contest 171 E - Red Scarf相关推荐

  1. AtCoder Beginner Contest 171 D Replacing 桶排序+及时更新数据

    AtCoder Beginner Contest 171   比赛人数10532  比赛开始后14分钟看到A题,之后,每过一分钟看到一道题 AtCoder Beginner Contest 171  ...

  2. AtCoder Beginner Contest 171 C.One Quadrillion and One Dalmatians

    AtCoder Beginner Contest 171 C.One Quadrillion and One Dalmatians 题目链接 这题真的坑啊,我想到了 26 进制却一直卡细节,因为 x ...

  3. AtCoder Beginner Contest 211 E - Red Polyomino(暴力+状态记录)

    E - Red Polyomino 暴力,对于状态的记录考虑下面用set<vector<string>> mp #include<bits/stdc++.h> us ...

  4. AtCoder Beginner Contest 171 B - Mix Juice

    B - Mix Juice Time Limit: 2 sec / Memory Limit: 1024 MB Score : 200200 points Problem Statement A sh ...

  5. AtCoder Beginner Contest 171 A - αlphabet

    A - αlphabet Time Limit: 2 sec / Memory Limit: 1024 MB Score : 100 points Problem Statement An upper ...

  6. AtCoder Beginner Contest 171 D - Replacing

    D - Replacing Time Limit: 2 sec / Memory Limit: 1024 MB Score : 400400 points Problem Statement You ...

  7. AtCoder Beginner Contest 245

    AtCoder Beginner Contest 245 文章目录 AtCoder Beginner Contest 245 A - Good morning B - Mex C - Choose E ...

  8. AtCoder Beginner Contest 202 D - aab aba baa(组合计数,字典序)

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Problem 有 AAA 和 aaa,BBB 个 bbb ,可以使用这 A+BA+BA+B 个字符任 ...

  9. AtCoder Beginner Contest 197 题解(A ~ F)

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 A - Rotate B - Visibility C - ORXOR D - Opposite ...

最新文章

  1. 如何做网络营销推广之网站SEO中title标签优化技巧!
  2. Freemarker的Null处理
  3. Java中方法签名signature、方法重载以及“两同两小一大”的方法覆盖(方法重写)总结
  4. Altium designer中导入CAD文件
  5. R语言观察日志(part21)--包的组件之元数据
  6. python numpy 写入、读取 .npz 压缩文件
  7. Gartner:阿里云亚太市场排名第一
  8. 1w存银行一年多少利息_一百万存银行一年利息多少?提前取出利息怎么算?
  9. Bailian2855 计算概论(刘志敏老师班)ACM测试题1【椭圆】
  10. mysql国外专业网站
  11. 【工具推荐】PDF和其他格式的相关的转换
  12. 实验报告四201521460014
  13. 使用参比溶液的作用是_电导仪使用步骤
  14. 规则引擎实现生产调度系统
  15. Vue源码学习之Vue对于闭包的使用
  16. 戴尔(DELL)成就Vostro15-7580 15.6英寸八代混合独显便携商务笔记本 5699元
  17. 华为手机怎么安装Google
  18. sqlserver 中isnull(Null,0) 和isnull(' ',0) 区别
  19. c语言源程序自动评判系统,源程序的自动评判系统.PDF
  20. 零知识证明(zero-knowledge proof)

热门文章

  1. python import无法导入该脚本的父目录下的另一个子目录的模块
  2. torch.nn.Module.eval
  3. C#通过COM组件调用IDL的pro程序
  4. Log4j 日志输出学习(Eclipse)
  5. 面试归来,感觉无望,下次再战
  6. 专业运维配的vsftpd.conf
  7. CSS + DIV 让页脚始终保持在页面底部
  8. MEF体验使用接口导出的优越性
  9. POSTMAN list参数传值
  10. Python可视化库Matplotlib的使用