ID—异或

Problem C. ID

Time Limit: 1000ms  Memory Limit: 100000k

Description

It is very cold in Harbin in the winter, but it is pretty warm in the Zhengxin Building. Today is Saturday, Teacher ABG want to play a trick on the only one student called NWL because he didn’t finish the MOOC.

At the beginning, every student is in the building. The teacher calls some students to sweep the snow on the playground out of the building, and sometimes he also call some students who are on the playground back to the building. At last, teacher ABG wants to leave only one student, NWL, on the playground out of the building. It means that the teacher ABG calls NWL’s ID ODD times, but called other students’ ID EVEN times, maybe more than twice. Now give you the list describing the students’ ID which the teacher called in order, please tell us NWL’s ID.

Input

The first line is an integer T, describes the number of tests. Then T tests.

In each test, the first line is an integer N, describes the number of IDs on the list.

Then followed N lines, each line contains an integer M, describes one ID on the list.

Output

T lines. Each line, an integer, the NWL’s ID

Sample

Input

Output

3

3

1140310000

1140310000

1140310000

1

1140310002

5

1

2

2

2

2

1140310000

1140310002

1

 

 

Hint

1<=T<=10

1<=N<=1,000,000

1<=M<=1,159,999,999

The sum of N in the input file is no more than 3,000,000, all the input are integers and correct.

 

异或求解

  1. #include<iostream>  
  2. #include<cstdio>  
  3. #include<ctime>  
  4. #include<cstdlib>  
  5. using namespace std;  
  6. int m,t;  
  7. int n;  
  8. int ans;  
  9. int main()  
  10. {  
  11.     scanf("%d",&t);  
  12.     while(t--)  
  13.     {  
  14.         ans=0;  
  15.         scanf("%d",&m);  
  16.         for(int i=1; i<=m; i++)  
  17.         {  
  18.             scanf("%d",&n);  
  19.             ans^=n;  
  20.         }  
  21.       printf("%d\n",ans);  
  22.     }  
  23.     return 0;  
  24. }  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值