Ignatius and the Princess IV HDU 1029】的更多相关文章

#include<iostream> #include<cstring> #include<cmath> #include<cstdio> #include<algorithm> #include<stack> #include<queue> using namespace std; ; int a[N]; int main() { int n; while(cin>>n&&n) { ; ; ;…
题目大意: n个数字,找出其中至少出现(n+1)/2次的数字,并且保证n是奇数. 题解:这道题数组是不能用的,因为题目没有明确输入的数据范围,比如输入了一个1e9,数组肯定开不了这么大.所以要用map来记录每个数字出现的次数,边输入边记录,然后找到满足题意的数即可. code: #include<bits/stdc++.h> using namespace std; map<int,int>mp; int main(){ int n; while(scanf("%d&qu…
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…
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…
传送门: 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…
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…
Ignatius and the Princess IV Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32767K (Java/Other) Total Submission(s) : 7   Accepted Submission(s) : 3 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description "OK, you a…
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)Total Submission(s): 51503    Accepted Submission(s): 23178 Problem Description "OK, you are not too bad, em... But you can never pass the…
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…
Ignatius and the Princess IV 点我跳转到题面 点我一起学习STL-MAP 题意分析 给出一个奇数n,下面有n个数,找出下面数字中出现次数大于(n+1)/2的数字,并输出. 用map做出映射,然后迭代器检查是否满足输出条件,是的话输出即可. 代码总览 /* Title:HDOJ.1029 Author:pengwill Date:2016-11-21 */ #include <iostream> #include <stdio.h> #include &l…