题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1029 题目大意: 多组数据,每组数据先给一个n,然后给n各数字,找出n各数字中出现了至少(n+1)/2次的数字并输出(保证n为奇数) 看到这题被分类进了dp我还是有点懵逼,我不知道我这算不算dp做法. 我是用的桶排序思想, 由于数据范围如此,直接进行遍历桶是会炸时间的, 所以多开一个数组记录下出现过的数字就行. 题不难 #include<cstdio> #include<cstring>…
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)Total Submission(s): 43629    Accepted Submission(s): 19213 Problem Description "OK, you are not too bad, em... But you can never pass the…
给你n个数字,请你找出出现至少(n+1)/2次的数字. 输入 本题包含多组数据,请处理到EOF: 每组数据包含两行. 第一行一个数字N(1<=N<=999999) ,保证N为奇数. 第二行为N个用空格隔开的整数. 输出 对于每组数据,输出一行,表示要求找到的那个数 样例输入 5 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 样例输出 3 5 1 思路:第一种思路是将数组排序,由于其出现(n+1)/2   次,故中位数一定是要找的那个数.时…
Ignatius and the Princess IV  先搬中文 Descriptions:   给你n个数字,你需要找出出现至少(n+1)/2次的数字 现在需要你找出这个数字是多少? Input 本题包含多组数据,请处理到EOF: 每组数据包含两行. 第一行一个数字N(1<=N<=999999) ,保证N为奇数. 第二行为N个用空格隔开的整数. Output 对于每组数据,输出一行,表示要求找到的那个数 Sample Input 5 1 3 2 3 3 11 1 1 1 1 1 5 5…
"OK, you are not too bad, em... But you can never pass the next test." feng5166 says.  "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 a…
<题目链接> 题目大意:给你一段序列,问你在这个序列中出现次数至少为 (n+1)/2 的数是哪个. 解题分析: 本题是一道水题,如果用map来做的话,就非常简单,但是另一个做法还比较巧妙. 解法一: #include <cstdio> int main() { int n,t,cnt,result; while(scanf("%d",&n)!=EOF){ cnt=; ;i<n;i++){ scanf("%d",&t);…
HDU 1029 Ignatius and the Princess IV (思维题,排序?) Description "OK, you are not too bad, em... But you can never pass the next test." feng5166 says. "I will tell you an odd number N, and then N integers. There will be a special integer among t…
HDU 1029 题目大意:给定数字n(n <= 999999 且n为奇数 )以及n个数,找出至少出现(n+1)/2次的数 解题思路:n个数遍历过去,可以用一个map(也可以用数组)记录每个数出现的次数, 若次数一旦达到(n+1)/2,即输出a[i] 注意能出现(n+1)/2次数的最多只有一个 /* HDU 1029 *Ignatius and the Princess IV --- dp */ #include <cstdio> #include <cstring> #in…
Ignatius and the Princess IV 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1029 借鉴链接:https://blog.csdn.net/tigerisland45/article/details/52146154 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)Total Submission(s): 4…
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)Total Submission(s): 27227    Accepted Submission(s): 11562 Problem Description "OK, you are not too bad, em... But you can never pass the…