hdu2095 find your present (2)(C语言
来源:互联网 发布:淘宝代购网店怎么开 编辑:程序博客网 时间:2024/05/24 22:44
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
Author
8600
Source
HDU 2007-Spring Programming Contest - Warm Up (1)
C语言AC代码
#include <stdio.h>void main(){ int s,n,a; while(scanf("%d",&n)&&n) { s=0; while(n--) { scanf("%d",&a); s=s^a; } printf("%d\n",s); }}注意:
1、a^b = b^a。
2、(a^b)^c = a^(b^c)。
3、a^b^a = b。
对于一个任意一个数n,它有几个特殊的性质:
1、0^n = n。
2、n^n = 0。
2、(a^b)^c = a^(b^c)。
3、a^b^a = b。
对于一个任意一个数n,它有几个特殊的性质:
1、0^n = n。
2、n^n = 0。
阅读全文
0 0
- hdu2095 find your present (2)(C语言
- hdu2095 find your present (2)
- hdu2095 find your present (2)
- hdu2095 find your present(2)
- HDU2095 find your present (2)
- HDU2095 find your present (2)【水题】
- HDU1563 HDU2095 Find your present!
- hdu2095 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)
- 归并排序的算法应用
- JavaSE-Headfirst Java笔记
- 19个javascript提高编码效率技巧
- 快乐数
- JavaScript的内置对象 2017-07-31
- hdu2095 find your present (2)(C语言
- RHCE——配置和保护OPENSSH服务
- Objective
- Guava Cache 数据变化实现回调的监听器RemovalListener
- Java数值类型提升机制
- 感想一篇and博客开张
- DC -19 :树树树02(接DC
- java 方法中的形参传值
- 在java中 i++和++i有什么区别