HDOJ 1563 Find your present!
来源:互联网 发布:杨君优化人生全本 编辑:程序博客网 时间:2024/05/29 11:58
Find your present!
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3356 Accepted Submission(s): 2226
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.
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
51 1 3 2 231 2 10
Sample Output
32
这道题就是让找只出现一次的那个号码,与2095不同之处在于此题可以用数组,把号码存到数组中,然后扫描数组,把出现的号码和号码的个数放到结构体中,结构体是号码和号码出现的次数,然后输出号码出现次数是1对应的那个号码。
AC CODE (1) 和 2095一样#includeint main(){ int n; int x, b; int i; while (scanf("%d", &n), n){ b = 0; for (i = 0; i < n; i++){ scanf("%d", &x); b = b ^ x; } printf("%d\n", b); } return 0;}AC CODE (2)#include#includestruct NUM{ int N; int num;}num[400];int main(){ int M,i,j,k,a[400]; while(scanf("%d",&M)&&M!=0) { memset(a,0,sizeof(a)); for(i=0;i scanf("%d",&a[i]); for(i=0;i<400;i++) num[i].num=0; for(i=0,j=0;i { if(a[i]!=-1) num[j].N=a[i]; else continue; for(k=0;k if(num[j].N==a[k]) { num[j].num+=1; a[k]=-1; } j+=1; } for(i=0;i if(num[i].num==1) break; printf("%d\n",num[i].N); } return 0;}
0 0
- HDOJ 1563 Find your present!
- Hdoj-1563-Find your present!
- hdoj-1563-Find your present!
- HDOJ 1563 Find your present!
- hdoj.1563 Find your present! 20140825
- HDOJ-1563-Find your present! 解题报告
- hdoj 1563 Find your present!&&2095 Find your present(2) 异或运算
- HDOJ(HDU) 1563 Find your present!(异或)
- HDOJ 2095 find your present (2)
- hdoj 2095 find your present (2)
- hdoj.2095 find your present (2) 20140804
- hdoj 2095 find your present (2)
- HDOJ 2095 find your present (2)
- HDOJ find your present (2) 2095
- HDOJ 2095 find your present (2)
- HDOJ 2095-find your present (2)
- HDOJ 2095 find your present (2)
- HDOJ 2095 find your present (2)
- SQL Server 执行计划操作符详解(3)——计算标量(Compute Scalar)
- 第十一周项目1 - 二叉树算法验证.cpp
- Assembly x64 Intro - SSE2 IDCT
- 第八周 项目三 顺序串算法(2)
- linux 关机重启 shutdown和reboot的区别
- HDOJ 1563 Find your present!
- ucosIII 系统任务
- Python包安装——mayavi安装
- 第10周 【项目2 - 二叉树遍历的递归算法】
- Assembly x64 Intro - SSE2 IDCT I16X16 DC
- 创业者融资攻略:什么时候可以“视金钱如粪土”?
- [转]在SpringMVC中获取request对象的几种方式
- 【代码笔记】iOS-传身份证号码可返回生日字符串
- 第16周项目1-选择排序之堆排序(6)