POJ 2092 Grandpa is Famous
| Time Limit: 2000MS | Memory Limit: 30000K | |
| Total Submissions: 7153 | Accepted: 3624 |
Description
The International Bridge Association (IBA) has maintained, for several years, a weekly ranking of the best players in the world. Considering that each appearance in a weekly ranking constitutes a point for the player, grandpa was nominated the best player ever because he got the highest number of points.
Having many friends who were also competing against him, grandpa is extremely curious to know which player(s) took the second place. Since the IBA rankings are now available in the internet he turned to you for help. He needs a program which, when given a list of weekly rankings, finds out which player(s) got the second place according to the number of points.
Input
- in each test case there is exactly one best player and at least one second best player,
- each weekly ranking consists of M distinct player identifiers.
The end of input is indicated by N = M = 0.
Output
Sample Input
4 5
20 33 25 32 99
32 86 99 25 10
20 99 10 33 86
19 33 74 99 32
3 6
2 34 67 36 79 93
100 38 21 76 91 85
32 23 85 31 88 1
0 0
Sample Output
32 33
1 2 21 23 31 32 34 36 38 67 76 79 88 91 93 100
题目大意:求出现次数第二多的数。
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std; int nCount[]; int main()
{
int m, n;
int a;
while(scanf("%d%d", &m, &n) != EOF)
{
if (m == && n == )
{
break;
}
int index = ;
memset(nCount , , sizeof(nCount));
for(int i = ; i < m; i++)
{
for (int j = ; j < n; j++)
{
scanf("%d", &a);
nCount[a]++;
}
}
int max1 = -, max2 = -;
for (int i = ; i <= ; i++)
{
if (nCount[i] > max1)
{
max2 = max1;
max1 = nCount[i];
}
else
{
if (nCount[i] > max2)
{
max2 = nCount[i];
}
}
}
int nsum = ;
for (int i = ; i <= ; i++)
{
if (nCount[i] == max2)
{
if (nsum != )
{
printf(" %d", i);
}
else
{
nsum++;
printf("%d", i);
}
}
}
printf("\n");
}
return ;
}
POJ 2092 Grandpa is Famous的更多相关文章
- POJ 2092 Grandpa is Famous【水---找出现第二多的数】
链接: http://poj.org/problem?id=2092 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#probl ...
- Poj 2092 Grandpa is Famous(基数排序)
题目链接:http://poj.org/problem?id=2092 思路分析:先统计数据,在根据Count降序排序,Count相等时按照Num升序排序:再输出Count第二大的所有Num: 代码如 ...
- (使用STL自带的排序功能进行排序7.3.2)POJ 2092 Grandpa is Famous(结构体排序)
/* * POJ_2092.cpp * * Created on: 2013年11月1日 * Author: Administrator */ #include <iostream> #i ...
- POJ 1228 - Grandpa's Estate 稳定凸包
稳定凸包问题 要求每条边上至少有三个点,且对凸包上点数为1,2时要特判 巨坑无比,调了很长时间= = //POJ 1228 //稳定凸包问题,等价于每条边上至少有三个点,但对m = 1(点)和m = ...
- POJ 1228 Grandpa's Estate(凸包)
Grandpa's Estate Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11289 Accepted: 3117 ...
- poj - 1228 - Grandpa's Estate
题意:原来一个凸多边形删去一些点后剩n个点,问这个n个点能否确定原来的凸包(1 <= 测试组数t <= 10,1 <= n <= 1000). 题目链接:http://poj. ...
- POJ 1228 Grandpa's Estate 凸包 唯一性
LINK 题意:给出一个点集,问能否够构成一个稳定凸包,即加入新点后仍然不变. 思路:对凸包的唯一性判断,对任意边判断是否存在三点及三点以上共线,如果有边不满足条件则NO,注意使用水平序,这样一来共线 ...
- POJ 1228 Grandpa's Estate(凸包唯一性判断)
Description Being the only living descendant of his grandfather, Kamran the Believer inherited all o ...
- POJ 1228 Grandpa's Estate --深入理解凸包
题意: 判断凸包是否稳定. 解法: 稳定凸包每条边上至少有三个点. 这题就在于求凸包的细节了,求凸包有两种算法: 1.基于水平序的Andrew算法 2.基于极角序的Graham算法 两种算法都有一个类 ...
随机推荐
- CF895 E. Eyes Closed(线段树 期望)
题意 Sol 今天考试的T3,,我本来留了一个小时去写.但是T2一刚就刚了两个小时 最后也没来的及写.. 然后考完 开始写,,25min就A了.. 感觉自己太高估自己的思维,太低估自己的码力了... ...
- ES-Mac OS环境搭建(2)
下载 进入官网,选择downloads进入下载页. 选择elasticsaerch下载. 新的页面中,下拉选择历史版本. 下拉选择elasticsearch和版本,然后点击下载. 选择MACOS/LI ...
- Core Foundation 框架
Core Foundation框架 (CoreFoundation.framework) 是一组C语言接口,它们为iOS应用程序提供基本数据管理和服务功能.下面列举该框架支持进行管理的数据以及可提供的 ...
- windows中安装模拟器后修改模拟器中的hosts方法
1.背景 有的时候我们测试安卓的app需要绑定hosts,这个时候我们如果只是修改PC机器上的hosts,然而在模拟器中并不生效.这个时候我们就需要修改模拟器中的hosts. 模拟器中的hosts为只 ...
- CPP-基础:strcpy之于C++(
以下对strcpy函数错误的是? char atr1[]="string"; ]; char *str3; char *str4="sting"; A.strc ...
- java运行环境jdk的安装和环境变量的配置教程
jdk的下载与安装 一.官网下载jdk 1.百度搜索jdk,进入官网,如下图所示: 官网下载jdk图1 2.在官网网站中找到合适的版本下载(以最新版本为例),如下图所示: 官网下载jdk图2 官网下载 ...
- IP数据包的校验和算法
1.算法思路: IP/ICMP/IGMP/TCP/UDP等协议的校验和算法都是相同的,算法如下: 在发送数据时,为了计算IP数据包的校验和.应该按如下步骤: (1)把IP数据包的校验和字段置为0: ( ...
- 628. Maximum Product of Three Numbers@python
Given an integer array, find three numbers whose product is maximum and output the maximum product. ...
- Fortran学习笔记4(循环语句)
Fortran学习笔记4 Fortran学习笔记4 逻辑运算 循环 Do语句 Do-While循环 循环控制 循环应用实例 逻辑运算 if命令需要和逻辑运算表达式搭配才能起到很好的效果.下面分别列出F ...
- HDU-1455-木棒
这题的话,我们,定义一个结构体,然后把木棒从大到小排序. 这些木棒如果是由多根等长木棒组成的,那目标长度一定大于等于其中最长的木棒长度,所这就是我们搜索的下限. 上限就是所有的木棒组成了一根木棒,就是 ...