hdoj-1563-Find your present!
2016-05-27 17:43
316 查看
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.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<=200, and n is odd) at first. Following that, n positive integers will be given in a line. 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
5
1 1 3 2 2
3
1 2 1
0
Sample Output
3
2
位运算xjb搞一下
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.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<=200, and n is odd) at first. Following that, n positive integers will be given in a line. 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
5
1 1 3 2 2
3
1 2 1
0
Sample Output
3
2
位运算xjb搞一下
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N = 200; int num , n, ans; int main() { while (~scanf("%d", &n) && n) { for (int i=0; i<n; ++i) scanf("%d", &num[i]); ans = num[0]; for (int i=1; i<n; ++i) ans ^= num[i]; printf("%d\n", ans); } return 0; }
相关文章推荐
- background-position的百分比是怎么计算定位的
- 安装pods 遇到的坑
- iOS解决警告ld: warning: directory not found for option ''
- Qt之布局管理器
- Android 探究 LayoutInflater setFactory
- 快速排序的优化
- 自定义UI的时候,通常到CGContextRef进行绘图,以下为详细API的叙述
- 设计模式-策略模式
- iOS获取当前 年月日和星期
- ehcache memcache redis 三大缓存比较
- AppConext 的onCreate方法执行时机
- 操作系统
- 2016/5/27 1000. Hex to decimal
- Spark定制班第15课:Spark Streaming源码解读之No Receivers彻底思考
- Java学习笔记之Java中的包
- fm单体声和立体声的切换
- 今天对二级指针的深入理解
- 转载别人对虚函数的解释,方便以后查找
- Android Studio 查看Shar1码
- 软件工程 寻找小水王