- 浏览: 35930 次
文章分类
- 全部博客 (41)
- 卧鸟个去 (2)
- Transform (2)
- Mathmatic (9)
- Plant-Tree (7)
- Data-Struct (12)
- Red-Black-Tree (1)
- Radix-Tree (1)
- Trie (2)
- String (4)
- BST (2)
- Amazing-Union-Find-Set (1)
- HDU (27)
- OJ (32)
- BFS (3)
- Pretty-Suffix-Array (2)
- POJ (6)
- Graceful-Segment-Tree (2)
- Geometry (6)
- Priority-Queue (2)
- Dynamic-Programing (1)
- DP (3)
- LCS (1)
- Convex-Hull (2)
- Triangulation (1)
- DFS (3)
- Combinatorial-Mathematics (2)
- Big-Number (1)
- Statistic (3)
- STL (1)
- Shortest-Path (3)
- ZOJ (1)
- Leftist-Tree (1)
- Prime (1)
- Binary-Index-Tree (1)
- (1)
- Stack (1)
- SPFA (0)
- CRT (1)
find your present (2)
Time Limit: 1000/2000 MS (Java/Others)Memory Limit: 32768/1024 K (Java/Others)
Total Submission(s): 6852Accepted Submission(s): 2509
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
5 1 1 3 2 2 3 1 2 1 0
Sample Output
3 2use scanf to avoid Time Limit ExceededHintHint
Author
8600
Source
Recommend
8600
呢个题目,我用左我地一个师兄叫linda既牛人既一种异或运算既妙用。
其实就系一个数n, n^n = 0 即系如果有累异或变量tsu 对n 进行偶数次异或,甘样 tsu = 0。
另一方面如果进行奇数次异或,tsu= n。
尼条题目就系要搵到出现奇数次既数字,所以直接不断异或就ok。
贴代码:
4313813 | 2011-08-02 16:08:28 | Accepted | 2095 | 218MS | 188K | 227 B | C++ | 10SGetEternal{(。)(。)}! |
代码系够短,不过^运算其实系好费时间噶。
发表评论
-
HDU 1370 Biorhythms
2011-08-03 10:27 1149Biorhythms Time Limit: 2000/10 ... -
HDU 1075 What Are You Talking About
2011-08-04 11:00 831What Are You Talking About Tim ... -
HDU 1058 Humble Numbers
2011-08-02 15:55 1168Humble Numbers Time Limit: 200 ... -
HDU 1022 Train Problem I
2011-08-02 21:00 994Train Problem I Time Limit: 20 ... -
2142 HDU box
2011-08-02 21:21 733box Time Limit: 3000/1000 MS ( ... -
HDU 2151 Worm
2011-08-01 20:48 784Worm Time Limit: 1000/1000 MS ... -
HDU 2722 Here We Go(relians) Again
2011-08-02 00:06 968Here We Go(relians) Again Time ... -
HDU 3791 二叉搜索树
2011-08-02 14:26 1160二叉搜索树 Time Limit: 20 ... -
PKU 2352 Stars
2011-07-31 21:47 983Stars Time Limit: 1000MS ... -
PKU 2774 Long Long Message
2011-07-31 21:26 860Long Long Message Time Li ... -
PKU 2777 Count Color
2011-07-31 21:31 767Count Color Time Limit: 1 ... -
HDU 2098 分拆素数和
2011-07-31 21:08 1013分拆素数和 Time Limit: 1000/1000 MS ... -
ZOJ 3512 Financial Fraud .
2011-07-31 20:49 1226Financial Fraud Time Limit: 3 ... -
HDU 1798 Tell me the area .
2011-07-31 20:47 1069Tell me the area Time Limit: 3 ... -
HDU 2962 Trucking .
2011-07-31 20:46 638Trucking Time Limit: 20000/100 ... -
HDU 1596 find the safest road .
2011-07-31 20:45 569find the safest road Time Limi ... -
HDU 2553 N皇后问题 .
2011-07-31 20:20 658N皇后问题 Time Limit: 2000/1000 MS ... -
HDU 1392 Surround the Trees .
2011-07-31 20:19 756Surround the Trees Time Limit: ... -
HDU 1234 开门人和关门人 .
2011-07-31 20:17 639开门人和关门人 Time Limit: 2000/1000 ... -
HDU 1316 How Many Fibs? .
2011-07-31 20:15 941How Many Fibs? Time Limit: 200 ...
相关推荐
HDU的1250,主要是利用高精度加法,但是代码有点繁琐,效率不是很高
杭电ACMhdu1163
HDU1059的代码
hdu1001解题报告
hdu 1574 passed sorce
HDU的一题........HDU DP动态规
hdu2101AC代码
hdu acm 教案 搜索入门 hdu acm 教案 搜索入门
搜索 dfs 解题代码 hdu1241
2-sat---hdu3062,代码详尽,清晰,格式规范,亲测无误。
hdu 5007 Post Robot 字符串枚举。 暴力一下就可以了。
hdu acm 教案 动态规划(1) hdu acm 教案 动态规划(1)
hdu 1166线段树代码
自己做的HDU ACM已经AC的题目
ACM HDU题目分类,我自己总结的大概只有十来个吧
HDU最全ac代码
hdu动态规划算法集锦
hdu题目分类
HDU图论题目分类
Hdu 1237 解题代码