hdu 1563 Find your present!

Find your present!

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3579    Accepted Submission(s): 2386

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

位运算:

 1 #include <iostream>
 2 using namespace std;
 3
 4 int main(){
 5     int n, num;
 6     while(cin >> n && n != 0){
 7         int ans = 0;
 8         for(int i = 0; i < n; i++){
 9             cin >> num;
10             ans = ans ^ num;
11         }
12         cout << ans << endl;
13     }
14     return 0;
15 }
时间: 2024-10-10 14:08:00

hdu 1563 Find your present!的相关文章

HDOJ(HDU) 1563 Find your present!(异或)

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,

hdu 2095 find your present (2) 找到只出现一次的数字

find your present (2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/1024 K (Java/Others) Total Submission(s): 15349    Accepted Submission(s): 5821 Problem Description In the new year party, everybody will get a "special present"

hdu 2095 find your present(2)

find your present (2) Time Limit: 1000/2000 MS (Java/Others) Memory Limit: 32768/1024 K (Java/Others) Total Submission(s): 5186 Accepted Submission(s): 1513   Problem Description In the new year party, everybody will get a "special present".Now

杭电 HDU ACM 1563 Find your present!

Find your present! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3096    Accepted Submission(s): 2051 Problem Description In the new year party, everybody will get a "special present".No

(HDUSTEP 2) hdu 2095 find your present (2)(找到出现奇数次的那个数)

题目如下: find your present (2) Time Limit: 1000/2000 MS (Java/Others) Memory Limit: 32768/1024 K (Java/Others) Total Submission(s): 6275 Accepted Submission(s): 1639   Problem Description In the new year party, everybody will get a "special present"

HDU 2095 find your present(异或)

题意 求一组数中只出现过奇数次的数  输入保证只有一个数满足 知道一个数与自己的异或等于0  与0的异或等于自己就行咯 #include<cstdio> using namespace std; int main() { int n, t, ans; while(scanf("%d", &n), n) { ans = 0; for(int i = 1; i <= n; ++i) { scanf("%d", &t); ans = an

hdu 2095 find your present (2)

题意:给n个正整数,并保证只有一个数是与众不同的,要你找出与众不同的数. 代码: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int a[1000005]; int main() { int n; while(scanf("%d",&n)&&n) { for(int i=0; i<n; i++) scanf(&qu

HDU 2095 find your present (2) 异或

异或 暴力开数组,然而明显不过,要求32768k,结果超时了 #include <cstdio> #include <cstring> int book[1000000]; int main() { int n; while (scanf("%d", &n) && n) { int a; memset(book, 0, sizeof(book)); for (int i = 0; i < n; i++) { scanf("

zjgsu第五场解题报告

B.hdu2522 A simple problem 求小数循环节的思路可以看看这个链接 http://www.cnblogs.com/hxsyl/p/3330481.html 1/n的循环节最多有(n-1)个数,只要用长除法得到第一次余数重复,前面的的商就是答案 n也可以是负数 #include <iostream> #include <cstdio> #include <cmath> #include <cstring> using namespace