动态规划: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 ( ...
随机推荐
- 第十三周翻译:SQL Server安全级别1:SQL Server安全性概述
SQL Server安全级别1:SQL Server安全性概述 源自:Stairway to SQL Server Security Level 1: Overview of SQL Server S ...
- EF为什么向我的数据库再次插入已有对象?(ZT)
最近做了个多对多对实体对象,结果发现每次只要增加一个子实体,就会自动添加一个父实体进去,而不管该父实体是否已经存在. 找了好久,终于找到这篇文章,照文章内容来看,应该是断开连接导致的. 原文地址:ht ...
- ECharts是我接触过的最优秀的可视化工具,也是进步最快的软件,希望它早日成为世界级的开源项目。
ECharts的广泛网址: http://echarts.baidu.com/doc/example.html 零编程玩转图表: http://tushuo.baidu.com/?qq-pf-to=p ...
- GitHub简单命令行# 使用命令行传代码到GitHub
第一次提交代码到Github 第一步: 建立本地仓库cd到你的本地项目根目录下,执行git命令 cd到本地项目 git init 第二步: 将本地项目工作区的所有文件添加到暂存区 git add . ...
- free - 显示系统中已用和未用的内存空间总和.
总览 (SYNOPSIS) free [-b | -k | -m] [-o] [-s delay ] [-t] [-V] 描述 (DESCRIPTION) free 显示 系统中 已用和未用的 物理内 ...
- final关键字所修饰的类有什么特点
Java关键字final有“这是无法改变的”或者“终态的”含义,它可以修饰非抽象类.非抽象类成员方法和变量. final类不能被继承,没有子类,final类中的方法默认是final的. final方法 ...
- 【搜索】P1219 八皇后
题目描述 检查一个如下的6 x 6的跳棋棋盘,有六个棋子被放置在棋盘上,使得每行.每列有且只有一个,每条对角线(包括两条主对角线的所有平行线)上至多有一个棋子. 上面的布局可以用序列2 4 6 1 3 ...
- 实训day02 python
一.数据类型 列表: 定义:在[]内,可以存放多个任意类型的值,并以逗号隔开: 一般用于存放学生的爱好,课堂的周期等. 定义一个学生列表,可存放多个学生 students = ['A','B','C' ...
- python之str (字符型)
用途: 存储少量的数据,+ *int 切片, 其他操作方法 切片还是对其进行任何操作,获取的内容全部是strl类型 存储数据单一 格式: 在python中用引号引起来的就是字符串 '今天吃了没?' 1 ...
- PHP08 数组和数据结构
学习要点 数组的分类 数组的定义 数组的遍历 预定义数组 数组的相关处理函数 PHP操作数组需要注意的细节 数组的分类 关于PHP数组 由于PHP是弱类型的编程语言,所以PHP数组中的数组变量可以存储 ...