Ignatius and the Princess IV HDU - 1029 基础dp
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;
const int N = ;
int a[N];
int main()
{
int n;
while(cin>>n&&n)
{
int num=;
int ans=-;
for(int i=;i<n;i++)
{
cin>>a[i];
if(num==)
{
++num;
ans=a[i];
}
else
{
if(ans!=a[i])
num--;
else
num++;
}
}
cout<<ans<<endl;
}
}
Ignatius and the Princess IV HDU - 1029 基础dp的更多相关文章
- Ignatius and the Princess IV HDU 1029
题目大意: n个数字,找出其中至少出现(n+1)/2次的数字,并且保证n是奇数. 题解:这道题数组是不能用的,因为题目没有明确输入的数据范围,比如输入了一个1e9,数组肯定开不了这么大.所以要用map ...
- HDU 1029 基础dp
题目链接:Ignatius and the Princess IV 大意:就是在N个数里找出唯一一个至少出现过(N+1)/ 2 次的数. 1 <= N <= 999999. hash: / ...
- HDU 1029 Ignatius and the Princess IV / HYSBZ(BZOJ) 2456 mode(思维题,~~排序?~~)
HDU 1029 Ignatius and the Princess IV (思维题,排序?) Description "OK, you are not too bad, em... But ...
- HDU 1029 Ignatius and the Princess IV --- 水题
HDU 1029 题目大意:给定数字n(n <= 999999 且n为奇数 )以及n个数,找出至少出现(n+1)/2次的数 解题思路:n个数遍历过去,可以用一个map(也可以用数组)记录每个数出 ...
- HDU 1029 Ignatius and the Princess IV (map的使用)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1029 Ignatius and the Princess IV Time Limit: 2000/10 ...
- hdu 1029 Ignatius ans the Princess IV
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
- [ACM] hdu 1029 Ignatius and the Princess IV (动归或hash)
Ignatius and the Princess IV Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32767K (Ja ...
- HDU 1029 Ignatius and the Princess IV (动态规划、思维)
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
- 【HDU - 1029】Ignatius and the Princess IV (水题)
Ignatius and the Princess IV 先搬中文 Descriptions: 给你n个数字,你需要找出出现至少(n+1)/2次的数字 现在需要你找出这个数字是多少? Input ...
随机推荐
- Java中HashSet的重复性与判等运算重载
目录 还有一个故事--(平行世界篇) 还有一个美丽的梦幻家园:java.util 并且还有一个善战的达拉崩巴:HashSet 还有另外一个故事(不是虚假传说) 还有一对涂满毒药的夺命双匕:equals ...
- C语言中的弱符号(weak)用法及实例
一 符号概念: 在C语言中,有强符号和弱符号,符号简单来说就是函数.变量的名字,对于全局(非局部.非static)的函数和变量,能不能重名是有一定规矩的,强.弱符号就是针对这些全局函数和变量来说的. ...
- Vue.js 从源码理解v-for和v-if的优先级的高低
在vue.js里面,v-for和v-if是可以一起使用作用在某个元素上,网上看到一篇文章说永远不要把v-for和v-if同时用在同一个元素上,感觉有点瞎扯,官网也注明了可以一起使用的,还把两个指令的优 ...
- getElementsByTagName得到的对象
今天练习使用DOM创建html元素,想通过getElementsByTagName("body")获得body对象,然后建立和新创建的元素的关系,如下图: 其实,getElemen ...
- Hadoop架构及集群
Hadoop是一个由Apache基金会所开发的分布式基础架构,Hadoop的框架最核心的设计就是:HDFS和MapReduce.HDFS为海量的数据提供了存储,而MapReduce则为海量的数据提供了 ...
- JS中let、var、const的区别
先看let和var: 1. console.log(a); // undefined var a = 3; console.log(a); // Uncaught ReferenceError: Ca ...
- 如何知道一个路由器的 BSSID ?
使用 Mac 连接上这个路由器,然后使用 option 按 wifi 按钮,可以在详情页里找到. 有些路由中继的设置需要使用 BSSID ,比如 pandorabox openwrt
- HDU-1754 I Hate It (树状数组模板题——单点更新,区间查询最大值)
题目链接 ac代码(注意字符读入前需要注意回车的影响) #include<iostream> #include<cstdio> #include<cstring> ...
- webstorm 添加代码模板
file>setting>Live Templates>选择文件类型
- itest(爱测试) 4.4.0 发布,开源BUG 跟踪管理 & 敏捷测试管理软件
itest 简介 test 开源敏捷测试管理,testOps 践行者.可按测试包分配测试用例执行,也可建测试迭代(含任务,测试包,BUG)来组织测试工作,也有测试环境管理,还有很常用的测试度量:对于发 ...