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算法 两种算法都有一个类 ...
随机推荐
- IO多路复用机制(转)
1.简介 希望通过这篇文章,可以回答以下几个问题? 为什么需要IO多路复用? 什么是IO多路复用机制? IO多路复用的机制该怎么使用? epoll比select/poll相比,优势在哪里? 在了解I/ ...
- Android 面试总结~~~
一.面试中的问题 通过这几天的面试,总结了自己在面试过程中问到的问题,部分问题已经给出了答案,还有部分问题,还未有时间整理出来. ListView出现闪图.图片错乱原因解决方案 函数式编程 (Lamb ...
- SQL简单查询后续记录
--首先创建数据库TEST CREATE DATABASE TEST --创建表tb_user USE TEST CREATE TABLE [tb_user]( [name] [nvarchar] ( ...
- 如何修改IOS的默认字体
The first is workaround wich is iterating over all the labels in your UIView and change the labels f ...
- valgrind测试程序内存泄漏问题
1.用wincap将valgrind放入系统任意路径下,解压 2. 登录主机后台在需要测试程序的路径下运行此行命令: /opt/valgrind/bin/valgrind ./itb(例) 3. 跑 ...
- CPP-基础:友元
友元可以是一个函数,该函数被称为友元函数:友元也可以是一个类,该类被称为友元类. 我们已知道类具有封装和信息隐藏的特性.只有类的成员函数才能访问类的私有成员,程序中的其他函数是无法访问私有成员的.非成 ...
- shelll脚本,常见的脚本题目。
[root@localhost wyb]# cat 2quan.sh #!/bin/bash #写一个脚本,先要求输入用户名,然后让他输入一个数字,输的如果是数字给输出yes,不是数字,输出no #然 ...
- rhel7.3smb安装配置
rhel7.3smb安装配置 1.安装 yum -y install samba samba-client cifs-utils 2.配置开机自启动,覆盖原配置文件 systemctl enable ...
- React初识整理(四)--React Router(路由)
官网:https://reacttraining.com/react-router 后端路由:主要做路径和方法的匹配,从而从后台获取相应的数据 前端路由:用于路径和组件的匹配,从而实现组件的切换. 如 ...
- xadmin下设置“use_bootswatch = True”无效的解决办法
环境: python 2.7 django 1.9 xadmin采用源代码的方式引入到项目中 问题: 在xadmin使用的过程中,设置“use_bootswatch = True”,企图调出主题菜单, ...