find your present (2)
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.
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)的更多相关文章
- 跳转时候提示Attempt to present on while a presentation is in progress
出现这种情况,例如:我在获取相册图片后,直接present到另一个页面,但是上一个页面可能还未dismiss,所以,要在获取相册图片的dismiss方法的complete的block里面写获取图片及跳 ...
- find your present (感叹一下位运算的神奇)
find your present (2) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- HTTP Status 400 - Required String parameter 'userName' is not present 错误
HTTP Status 400 - Required String parameter 'userName' is not present 错误 先mark 有时间详细写 参考链接: https:/ ...
- Linux 克隆虚拟机引起的“Device eth0 does not seem to be present, delaying initialization”
虚拟机Vmware上克隆了一个Red Hat Enterprise Linx启动时发现找不到网卡,如下所示,如果你在命令窗口启动网络服务就会遇到"Device eth0 does not s ...
- required string parameter XXX is not present
@RequestParam jQuery调用方式: deleteFile: function(filePath) { return ajax({ method: 'POST', url: '/cm/s ...
- 启动网卡报:Device eth0 does not seem to be present”解决办法
Device eth0 does not seem to be present”解决办法 : 用ifconfig查看发现缺少eth0,只有lo:用ifconfig -a查看发现多出了eth1的信息. ...
- 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 ...
- 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 ...
- 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配置文 ...
- 虚拟机解决Device eth0 does not seem to be present 问题。
Device eth0 does not seem to be present... 出现这个问题基本上是因为虚拟机是克隆的导致机器的mac网卡不一致,所以系统识别网卡失败:
随机推荐
- 如何判断Android设备是手机还是平板?
转自:http://blog.csdn.net/zuolongsnail/article/details/8682950 Android开发需要适配手机和平板,有些需求在实现中就要判断设备是手机还是平 ...
- C++11模板的别名
[C++模板的别名] 参考:http://zh.wikipedia.org/wiki/C++0x#.E6.A8.A1.E6.9D.BF.E7.9A.84.E5.88.A5.E5.90.8D
- POJ 2653 Pick-up sticks(判断线段相交)
Pick-up sticks Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 7699 Accepted: 2843 De ...
- 应用c#读取带cookie的http数据
@(编程) private static string Login() { string url = string.Format("{0}/login-submit.html?identit ...
- HDU3635Dragon Balls(并查集)
http://acm.hdu.edu.cn/showproblem.php?pid=3635 题目意思是说n个球在n个城市. 每次操作把编号i的球所在的城市的所有的求全部一道另一城市B 每次询问访问编 ...
- 把我的Java项目部署到Linux系统
以前,还未毕业,凭借自己三脚猫的功夫,只会在Windows环境中使用tomcat容器把项目跑起来. 以前的操作是,利用Eclipse把项目导出成War包,放到tomcat的webApp文件夹中,鼠标点 ...
- CentOS6 下安装JDK7
1.下载JDK:http://www.oracle.com/technetwork/java/javase/archive-139210.html,选择Java SE 7,下载jdk-7u80-lin ...
- chrome 41 空格
chrome 41对半角空格的解析 当做一个汉字宽度来处理了. 导致很多网站出现异常. 目前能想到的方法是删掉用来规范格式的空格. 老版chrome chrome41 和讯网也有这种问题 有更好的处理 ...
- 局部化原理(Laplace渐进估计方法)
设$f(x)$于$[0,1]$上严格单调递减,且$f(0)=1,f(1)=0$,证明: $$\int_{0}^{1}f^{n}(x)dx \sim \int_{0}^{\delta}f^{n}(x), ...
- 关于.NET邮件的收发问题总结
转载:http://www.cnblogs.com/ustbwuyi/archive/2007/05/28/762581.html //取数据库中邮件信息中的最大发送时间,即最近接收到的一封邮件的时间 ...