2095 find your present (2)【水题】
来源:互联网 发布:手机上看图软件 编辑:程序博客网 时间:2024/06/18 17:08
find your present (2)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 18629 Accepted Submission(s): 7172
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
比较简单的一道题,就是判断哪个数只出现一次,排好序就行查找就可以了......
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int x[1000005],n;void slove(){sort(x,x+n);int cnt=0;for(int i=0;i<n;i+=2)//遍历{if(x[i]!=x[i+1])//查找{printf("%d\n",x[i]);return;}}}int main(){while(scanf("%d",&n),n){memset(x,0,sizeof(x));for(int i=0;i<n;++i){scanf("%d",x+i);}slove();}return 0;}
0 0
- 2095 find your present (2)【水题】
- 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)
- hdu 4969 Just a Joke(数学)
- 数据库学习2
- HDU 3376 Matrix Again(费用流)
- mysql性能优化
- CCLabelTTF解析
- 2095 find your present (2)【水题】
- 适配器Adapter(视图View):HashMap中entrySet实现
- nginx在linux平台下搭建
- Windows与Ubuntu之间共享文件
- python的真值
- http-url那些事
- C++中 volatile关键字的作用
- Centos 上 mantis 安装
- CCLabelBMFont解析