博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
7K - find your present (2)
阅读量:6605 次
发布时间:2019-06-24

本文共 1482 字,大约阅读时间需要 4 分钟。

In the new year party, everybody will get a "special present".Now it's your turn to get your special present, a lot of presents now putting on the desk, and only one of them will be yours.Each present has a card number on it, and your present's card number will be the one that different from all the others, and you can assume that only one number appear odd times.For example, there are 5 present, and their card numbers are 1, 2, 3, 2, 1.so your present will be the one with the card number of 3, because 3 is the number that different from all the others.

Input

The input file will consist of several cases. 

Each case will be presented by an integer n (1<=n<1000000, and n is odd) at first. Following that, n positive integers will be given in a line, all integers will smaller than 2^31. These numbers indicate the card numbers of the presents.n = 0 ends the input.

Output

For each case, output an integer in a line, which is the card number of your present.

Sample Input

51 1 3 2 231 2 10

Sample Output

32

Hint

use scanf to avoid Time Limit Exceeded // 0^n=n, n^n=0. And "you can assume that only one number appear odd times"
1 #include
2 int main() 3 { 4 int n, num, m; 5 while(scanf("%d", &n), n) 6 { 7 m=0; 8 while(n--) 9 {10 scanf("%d", &num);11 m^=num;12 }13 printf("%d\n", m);14 }15 return 0;16 }
View Code

 

转载于:https://www.cnblogs.com/goldenretriever/p/10357106.html

你可能感兴趣的文章
Planner .NET日历日程控件能给你的应用程序提供多种日历日程功能
查看>>
我的友情链接
查看>>
Linux压力测试
查看>>
JAVA中的线程机制(二)
查看>>
nginx安装与配置2(转载)
查看>>
Linux下Mongodb安装和启动配置
查看>>
2015 成长计划
查看>>
沈阳一饭店凌晨爆燃,燃气报警器时刻预防
查看>>
Redis 与 数据库处理数据的两种模式
查看>>
VUE2中axios的使用方法
查看>>
assert 断言
查看>>
CS 229 notes Supervised Learning
查看>>
2018.10.27-dtoj-3996-Lesson5!(johnny)
查看>>
DataTable转换成json字符串
查看>>
iOS网络协议----HTTP/TCP/IP浅析
查看>>
ubuntu 12.04 安装 redis
查看>>
IOS_CGRect
查看>>
Sql Server中不常用的表运算符之APPLY(1)
查看>>
【DM642】ICELL Interface—Cells as Algorithm Containers
查看>>
linux所有命令失效的解决办法
查看>>