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 ...
随机推荐
- redis教程-redis环境搭建安装(qq:1324981084)
需要整套redis缓存高可用集群教学视频的加qq:1324981084,本套视频从安装到集群的搭建和源码的解析,从零基础讲解. 1.利用命令将redis下载到/usr/local/文件夹下: wget ...
- Spark组件间通信
1.Spark组件之间使用RPC机制进行通信.RPC的客户端在本地编写并调用业务接口,接口在本地通过RPC框架的动态代理机制生成一个对应的实现类,在这个实现类中完成soket通信.远程调用等功能的逻辑 ...
- apue 外传
先上目录 chapter 3 [apue] dup2的正确打开方式 chapter 10 [apue] 等待子进程的那些事儿 chapter 14 [apue] 使用文件记录锁无法实现父子进程交互执行 ...
- kubernetes监控
总体设计思想 总体设计架构图Kubernetes monitoring architecture 设计介绍 监控分成两个部分 核心指标流程 包括的组件有 kubelet.resource estima ...
- 解决burpsuit 浏览器您的连接不是私密连接的问题
转载来源:https://www.cnblogs.com/hun-ya/p/8365255.html Burp Suite要抓HTTPS的包的话,是需要有Burp Suite的CA证书的 为什么要证书 ...
- Visual Studio Code中C/C++的环境配置
Visual Studio Code 的功能十分强大,但是对我这种小白不是很友好,它和其它的集成开发工具不同,Visual Studio Code (以下简称VS)自身其实仅仅是一个编辑器, 是不具备 ...
- docker - 如何清理硬盘中无关占用
背景 在使用docker进行容器化管理后会发现本次硬盘文件占用量在不断上升,并且即使是删除掉容器或者镜像也并不能释放掉对应的硬盘空间.本文将提供对应的docker命令用于真正释放掉该部分应被删除释放的 ...
- 分享10个免费或便宜的Photoshop替代工具
说到编辑照片和图像文件,一般很多人都使用photoshop软件.然而,使用现在的最新版本Photoshop CC每月最低也要支付980日元,感觉使用门槛有点高的人应该不少吧. 有一篇文章,推荐了10个 ...
- Linux系统的启动原理
Linux系统的启动原理 RHEL的启动原理BIOS自检-MBR-启动GRUB-加载内核-systemd的init进程 systemd的初始化进程加载需要的服务,挂载文件系统/etc/fstabsys ...
- 2018 IEEE极限编程大赛 题解
去年742,今年72,也算一种小小的进步. 明年前30(笑 1. Drawing Rooted Binary Trees 给定一个树的中序和前序的遍历,要求输出这棵树(包括空格的) #include ...