题意:输入n个数 n为奇数 问某个数出现的次数大于等于(N+1)/2的是 哪个 输出来Sample Input51 3 2 3 3111 1 1 1 1 5 5 5 5 5 571 1 1 1 1 1 1 Sample Output351 #include <queue> #include <map> using namespace std; map<int ,int> m ; int main() { int n ; while(scanf("%d"…
题目描述:输入n个整数,输出出现次数大于等于数组长度一半的数. 输入描述:每个测试输入包含 n个空格分割的n个整数,n不超过100,其中有一个整数出现次数大于等于n/2. 输出描述:输出出现次数大于等于n/2的数. 输入示例:3 9 3 2 5 6 7 3 2 3 3 3 输出示例:3 解法之一: /*输入n个整数,输出出现次数大于等于数组长度一半的数.*/ package practice_completed; import java.util.*; public class Test { p…
Sample Input5 //Tgreenredblueredred 统计颜色的次数 输出最多的颜色3pinkorangepink0 Sample Outputred pink # include <iostream> # include <cstdio> # include <cstring> # include <string> # include <map> using namespace std ; int main () { // f…
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…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1029 Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)Total Submission(s): 42359    Accepted Submission(s): 18467 Problem Description "OK, y…
此题无法用JavaAC,不相信的可以去HD1029题试下! Problem 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 them, you hav…
传送门:Ignatius and the Princess IV 题意:给n个数,找出出现次数大于等于(n+1)/2的那个数. 分析:大水题,排个序输出中间那个即可,这里随便写个HASHMAP找出次数最大那个. #include <algorithm> #include <cstdio> #include <cstring> #define N 1000010 #define inf 0x3f3f3f3f using namespace std; ; ; struct…
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…
解题报告: 题目大意:就是要求输入的N个数里面出现的次数最多的数是哪一个,水题.暴力可过,定义一个一位数组,先用memset函数初始化,然后每次输入一个数就将下标对应的上标对应的那个数加一,最后将整个数组都扫一遍, 看哪一个最大就可以了. #include<cstdio> #include<cstring> ]; int main() { int N,d; while(scanf("%d",&N)!=EOF) { memset(times,,sizeof…