2095:find your present (2)
来源:互联网 发布:淘宝偷窥客vip账号 编辑:程序博客网 时间:2024/05/21 08:55
Problem Description
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.
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
32use scanf to avoid Time Limit ExceededHintHint
分析:“^”异或运算符的经典应用
代码如下:
//acm 2095:find your present (2)#include <iostream>using namespace std;int main(){int n;while (cin >> n && n){int present_number,result = 0;//0与任何非零数n相异或均得到nwhile (n--){cin >>present_number;result ^= present_number;}cout << result << endl;}return 0;}
- hdu-2095-find your present (2)//1563-find your present
- 2095 find your present (2)
- 2095:find your present (2)
- 2095 find your present (2)
- find your present (2) 2095 *
- [2095]:find your present (2)
- find your present (2)
- find your present (2)
- find your present (2)
- find your present (2)
- find your present (2)
- find your present (2)
- find your present (2)
- find your present(2)
- find your present (2)
- find your present (2)
- find your present (2)
- find your present (2)
- 2317:Nasty Hacks
- Circular Queue
- java 入门 第一堂课
- linux inode
- Struts2_学习笔记(三)--------Action接收参数的四种方法
- 2095:find your present (2)
- IT青年创业降级论
- OpenCV学习笔记(17)双目测距与三维重建的OpenCV实现问题集锦(二)双目定标与双目校正
- HDU/HDOJ----4300 Clairewd’s message
- u-boot命令(一)
- 持续15秒的飞秋2.0
- Uboot命令(二)
- 黑马程序员---String的学习
- rail创建增删改功能