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 ...
随机推荐
- SVN状态图标不显示的解决办法
第一步:检查设置 右键->TortoiseSVN->setting->Icon Overlays->Status cache->default/Shell.或者 右键-& ...
- ORACLE中如何找出大表分布在哪些数据文件中?
ORACLE中如何找出大表分布在哪些数据文件中? 在ORACLE数据中,我们能否找出一个大表的段对象分布在哪些数据文件中呢? 答案是可以,我们可以用下面脚本来找出对应表的区.段分别位于哪些数据文件 ...
- idea如何做到多模块开发项目 收藏整理
idea如何做到多模块开发项目 <packaging>pom</packaging>是什么意思? idea 快捷键汇总
- DataX的使用——大数据同步技术
准备工作: 1.视频教学http://113.31.104.47/portal/#/course/dashboard/b34d160db64624732ef152a1118af11a 2.DataX的 ...
- warning Unexpected use of undefined no-undefined
报错翻译:警告意外使用未定义的no-undefined(谷歌这次翻译的不行) 报错原因undefined直接使用了,如下↓ 其实报错的意思就是这样不安全,看下面一个例子 var foo = undef ...
- JS简易计算器的实现,以及代码的优化
用JS实现简易计算器 首先创建结构和样式 <!DOCTYPE html> <html lang="en"> <head> <meta ch ...
- JS中let、var、const的区别
先看let和var: 1. console.log(a); // undefined var a = 3; console.log(a); // Uncaught ReferenceError: Ca ...
- python三程
1.1 进程与线程简介 1.什么是进程(process)?(进程是资源集合) 定义:1)进程是资源分配最小单位 2)当一个可执行程序被系统执行(分配内存资源)就变成了一个进程 1. 程序并不能单 ...
- 指数ETF基金的组合分析方法初探
本文在Creative Commons许可证下发布 试想一下,大多数基金“推荐”的配置策略都假设某种股票/债券组合.如果我们想寻求成本最小收益最高的组合(以yahoo finance上的数据来分析,因 ...
- QingTing.Fm-WPF是调用蜻蜓FMAPI 查询API内容展示,进行播放
QingTing.Fm 是调用蜻蜓FM API 查询界面内容,进行在线播放. Release地址下载 环境 Visual Studio 2019,dotNet Framework 4.6.1 SD ...