动态规划:Ignatius and the Princess IV
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
_int64 n,a;
while(scanf("%I64d",&n)!=EOF)
{
_int64 b=,c;
while(n--)
{
scanf("%I64d",&a);
if(b==)
{
c=a;
b++;
}
else
{
if(c==a)
b++;
else
b--;
}
}
printf("%I64d\n",c);
}
return ;
}
"I will tell you an odd number N, and then N integers. There will be a special integer among them, you have to tell me which integer is the special one after I tell you all the integers." feng5166 says.
"But what is the characteristic of the special integer?" Ignatius asks.
"The integer will appear at least (N+1)/2 times. If you can't find the right integer, I will kill the Princess, and you will be my dinner, too. Hahahaha....." feng5166 says.
Can you find the special integer for Ignatius?
1 3 2 3 3
11
1 1 1 1 1 5 5 5 5 5 5
7
1 1 1 1 1 1 1
5
1
动态规划:Ignatius and the Princess IV的更多相关文章
- 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 ans 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 --- 水题
HDU 1029 题目大意:给定数字n(n <= 999999 且n为奇数 )以及n个数,找出至少出现(n+1)/2次的数 解题思路:n个数遍历过去,可以用一个map(也可以用数组)记录每个数出 ...
- Ignatius and the Princess IV
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
- Ignatius and the Princess IV(乱搞一发竟然过了)
B - Ignatius and the Princess IV Time Limit:1000MS Memory Limit:32767KB 64bit IO Format:%I64 ...
- 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 ...
- (Arrays.sort() 或 map) Ignatius and the Princess IV hdu1029
Ignatius and the Princess IV 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1029 借鉴链接:https://blog.csd ...
- 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 ...
- HDOJ.1029 Ignatius and the Princess IV(map)
Ignatius and the Princess IV 点我跳转到题面 点我一起学习STL-MAP 题意分析 给出一个奇数n,下面有n个数,找出下面数字中出现次数大于(n+1)/2的数字,并输出. ...
- kuangbin专题十二 HDU1029 Ignatius and the Princess IV (水题)
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K ( ...
随机推荐
- MATLAB学习总结(1)
MATLAB学习总结(1) path help path cd(current directory) savepath pathtool
- How `delete’ works ?
这是2013年写的一篇旧文,放在gegahost.net上面 http://raison.gegahost.net/?p=21 February 16, 2013 How `delete’ works ...
- Java数据结构和算法(一)--栈
栈: 英文名stack,特点是只允许访问最后插入的那个元素,也就是LIFO(后进先出) jdk中的stack源码: public class Stack<E> extends Vector ...
- upupoo(网页壁纸)自主修改一:农历
最近在使用一款upupoo的壁纸软件,感觉还可以,主要是对其中html可设置为壁纸方面情有独钟 前几天在它的网页区发现了一个壁纸,感觉挺好: 感觉内容有点少,今天在工作空余时间就在其中加上了农历,同时 ...
- 数组合并--php
常用的合并数组方法有以下几种: 1 array_merge 2 '+' 3 array_merge_recursive 下面是一段对比的代码 $array1 = array(2,4," ...
- MYSQL数据库攻防与加固
这是“官方”原本的模样搬过来的..写的很粗略啊.还有篇详细的请查看:MySQL安全加固题目及答案参考解析 启动xserver-mysql,进入xserver-mysql,开始实验,实验步骤如下: 1. ...
- Jenkins中部署Sonar代码检查
1 安装并启动sonarqube docker pull sonarqube:7.5-community docker run \ --name sonarqube \ --network ci \ ...
- configparser ,subprocess , xlrd ,xlwt 模块
一,configparser模块 ''' configparser模块: 是什么: 用于解析配置文件的模块 配置文件的定义: 用于编写保存某个软件或某个系统的一系列参数的文件 设置参数 为什么需要配置 ...
- solr 时区问题
本人使用solr版本5.0.0,使用jetty启动 solr默认UTC时区,与我们相差八小时,按照网络上资料修改 C:\Users\hp\Desktop\solr-5.0.0\bin 下的solr.i ...
- PADS规则设计-对某一网络/元件单独设置规则
转载请注明出处,并附带本文网址https://www.cnblogs.com/brianblog/p/9894867.html, 在PADS规则设计中可能会遇到某个走线与另一个走线之间的间距,普通规则 ...