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.
 
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
 
Hint

use scanf to avoid Time Limit Exceeded

 

题目内存限制:1024K,所以不能简单地用数组存然后再处理。

为了节约内存,可以用STL里面的set,map等容器。

当容器里没有这个元素的时候,就插入这个元素,否则,删除这个元素。

最后,容器中肯定只剩下一个元素,便是我们所要的结果。

 #include <set>
#include <stdio.h>
using namespace std; int main(){
int n;
int i;
int temp;
set<int> S; while(){
scanf("%d",&n); if(n==)
break; for(i=;i<n;i++){
scanf("%d",&temp); if(S.find(temp)==S.end())
S.insert(temp); else
S.erase(temp);
} printf("%d\n",*S.begin());
S.clear();
} return ;
}

find your present (2)的更多相关文章

  1. 跳转时候提示Attempt to present on while a presentation is in progress

    出现这种情况,例如:我在获取相册图片后,直接present到另一个页面,但是上一个页面可能还未dismiss,所以,要在获取相册图片的dismiss方法的complete的block里面写获取图片及跳 ...

  2. find your present (感叹一下位运算的神奇)

    find your present (2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  3. HTTP Status 400 - Required String parameter 'userName' is not present 错误

    HTTP Status 400 - Required String parameter 'userName' is not present 错误 先mark  有时间详细写 参考链接: https:/ ...

  4. Linux 克隆虚拟机引起的“Device eth0 does not seem to be present, delaying initialization”

    虚拟机Vmware上克隆了一个Red Hat Enterprise Linx启动时发现找不到网卡,如下所示,如果你在命令窗口启动网络服务就会遇到"Device eth0 does not s ...

  5. required string parameter XXX is not present

    @RequestParam jQuery调用方式: deleteFile: function(filePath) { return ajax({ method: 'POST', url: '/cm/s ...

  6. 启动网卡报:Device eth0 does not seem to be present”解决办法

    Device eth0 does not seem to be present”解决办法 : 用ifconfig查看发现缺少eth0,只有lo:用ifconfig -a查看发现多出了eth1的信息. ...

  7. jQuery 跨域访问的三种方式 No 'Access-Control-Allow-Origin' header is present on the reque

    问题: XMLHttpRequest cannot load http://v.xxx.com. No 'Access-Control-Allow-Origin' header is present ...

  8. js跨域访问,No 'Access-Control-Allow-Origin' header is present on the requested resource

    js跨域访问提示错误:XMLHttpRequest cannot load http://...... No 'Access-Control-Allow-Origin' header is prese ...

  9. sudo: no tty present and no askpass program specified(转)

    sudo: no tty present and no askpass program specified 2012-11-30 09:30 5040人阅读 评论(1) 收藏 举报 修改sudo配置文 ...

  10. 虚拟机解决Device eth0 does not seem to be present 问题。

    Device eth0 does not seem to be present... 出现这个问题基本上是因为虚拟机是克隆的导致机器的mac网卡不一致,所以系统识别网卡失败:

随机推荐

  1. 面试题收集——Java基础部分(一)

    原博文出自于: http://www.cnblogs.com/xdp-gacl/p/3641769.html 感谢! 1.一个".java"源文件中是否可以包括多个类(不是内部类) ...

  2. POJ3345

    http://poj.org/problem?id=3345 大意: 大意是说现在有n个城市来给你投票,你需要至少拿到m个城市的赞成票.想要获得第i个城市的赞成需要花费w[i],有个条件就是某些城市是 ...

  3. HDU 4596 Yet another end of the world (数学,扩展欧几里德)

    题意:给出n组x,y,z.判断是否存在一个id使得id%x1∈(y1,z1),id%x2∈(y2,z2). 析: 设 id/x1=a , id/x2=b ,则 id-a*x1=u;   (1) id- ...

  4. commondline 之三 执行jar文件

    java [-options] -jar jarfile [args...] 点击查看获取可执行jar文件方法

  5. [Mac]ios应用发布流程

    准备: 苹果开发者账号 发布: Xcode-product-clean-Archive,将应用上传到https://itunesconnect.apple.com,创建一个新的app版本,填写app相 ...

  6. This is a sandbox of markdown

    A First Level Header A Second Level Header Now is the time for all good men to come to the aid of th ...

  7. 传统的Ado.net 参数设置:params SqlParameter[] commandParameters

    C#代码  ExecuteReader(string connectionString, CommandType commandType, string commandText, params Sql ...

  8. HTML第二天学习笔记

    今天看视频学习的第一个知识是HTML中的块元素<div>和行内元素<span>. <!doctype html> <html lang="en&qu ...

  9. 理解Web标准(网站标准)

    我觉得一名Web前端应该好好理解Web标准到底是什么,为什么要在我们的实际实践中遵循Web标准. 什么是Web标准.百度百科的解释是: WEB标准不是某一个标准,而是一系列标准的集合.网页主要由三部分 ...

  10. cmd下运行PowerShell命令

    PowerShell -Command "& {Get-EventLog -LogName security}"