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

Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32767 K (Java/Others)Total Submission(s): 6518    Accepted Submission(s): 2325 Problem Description "OK, you are not too bad, em... But you can never pass the n…
http://acm.hdu.edu.cn/showproblem.php?pid=1029 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…
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 链接: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): 13294    Accepted Submission(s): 5362 Problem Description "OK, you are not too bad, em... But you can never pass the…
B - Ignatius and the Princess IV Time Limit:1000MS     Memory Limit:32767KB     64bit IO Format:%I64d & %I64u Submit Status Description "OK, you are not too bad, em... But you can never pass the next test." feng5166 says. "I will tell y…
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…
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…
Ignatius and the Princess IV Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32767 K (Java/Others) 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…
此题无法用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…
解题报告: 题目大意:就是要求输入的N个数里面出现的次数最多的数是哪一个,水题.暴力可过,定义一个一位数组,先用memset函数初始化,然后每次输入一个数就将下标对应的上标对应的那个数加一,最后将整个数组都扫一遍, 看哪一个最大就可以了. #include<cstdio> #include<cstring> ]; int main() { int N,d; while(scanf("%d",&N)!=EOF) { memset(times,,sizeof…
kuangbin 专题 这题,有很多种解法. 第一种: 直接比较每个数出现次数. #include<iostream> #include<string> #include<algorithm> #include<cstdlib> #include<cstdio> #include<set> #include<map> #include<vector> #include<cstring> #inclu…
#include <bits/stdc++.h> using namespace std; int main(){ int n; while(~scanf("%d",&n)){ int x,ans,cnt = 0; while(n--){ scanf("%d",&x); if(cnt == 0){ ans = x; cnt++; }else{ if(x == ans) cnt++; else cnt--; } } printf("…
题意:求出现次数>=(N+1)/2的数 思路:排序后,输出第(N+1)/2个数 #include<iostream> #include<stdio.h> #include<algorithm> using namespace std; ]; int main(){ int n,i; while(~scanf("%d",&n)){ ;i<n;++i) scanf("%d",&a[i]); sort(a,a…
#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 4308 Saving Princess claire_ 分析: 两次BFS分别找出‘Y’.‘C’到达最近的‘P’的最小消耗.再算出‘Y’到‘C’的最小消耗,比较出最小值 代码: #include<iostream> #include<cstdio> #include<cstring> #include<queue> #include<string> using namespace std; const int inf=0xF…
Prince and Princess 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=4685 Description There are n princes and m princesses. Princess can marry any prince. But prince can only marry the princess they DO love. For all princes,give all the princesses tha…
 Ignatius and the Princess III Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Description "Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says.  "Th…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4685 题意:给出n个王子和m个公主.每个王子有一些自己喜欢的公主可以匹配.设最大匹配为M.那么对于每个王子,可以选择哪些自己喜欢的公主使得选择之后最大匹配仍为M? 思路:(1)首先,想到的一个方法是先求一次最大匹配.然后枚举每个王子喜欢的公主作为该王子的匹配,判断能否为之前匹配该公主的王子重新找到一个匹配.这样的复杂付太大. (2)改进:做法是先求一次最大匹配设为cnt,那么左边有n-cnt个王子还…
http://acm.hdu.edu.cn/showproblem.php?pid=4781 由于题目太长,这里就不直接贴了,直接说大意吧. 题目大意:有一个n个点,m条边的有向图,每条边的权值分别为1,2,3........m,让你构造满足下列条件的有向图. 1:每两个点之间最多只有一条有向边,且不存在自环. 2:从任意点出发都可以达到其他任意一个点,包括自己. 3:任意一个有向环的权值和都是3的倍数. 思路:首先我们可以将点1到n连成一条链,边的权值分别是1到n-1,然后点n到点1连一条边,…
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 have to tell me which i…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2077 还记得汉诺塔III吗?他的规则是这样的:不允许直接从最左(右)边移到最右(左)边(每次移动一定是移到中间杆或从中间移出),也不允许大盘放到小盘的上面.xhd在想如果我们允许最大的盘子放到最上面会怎么样呢?(只允许最大的放在最上面)当然最后需要的结果是盘子从小到大排在最右边.  Input输入数据的第一行是一个数据T,表示有T组数据. 每组数据有一个正整数n(1 <= n <= 20),表示有…
Prince and Princess Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 150    Accepted Submission(s): 46 Problem Description There are n princes and m princesses. Princess can marry any prince. But…