题目链接:http://poj.org/problem?id=2092

思路分析:先统计数据,在根据Count降序排序,Count相等时按照Num升序排序;再输出Count第二大的所有Num;

代码如下:

#include <iostream>
#include <string.h>
#include <algorithm> using namespace std; #define MAX_N ( 10000 + 20 )
struct Player
{
int Num;
int Count;
};
bool Cmp( Player a, Player b ); int main()
{
int n, m;
Player P[MAX_N]; while( scanf("%d %d", &n, &m) )
{
int Tmp, i, j; memset( P, , sizeof(P) ); if ( m == && n == )
break; for ( i = ; i < n; ++i )
for( j = ; j < m; ++j )
{
scanf( "%d", &Tmp );
P[Tmp].Num = Tmp;
P[Tmp].Count++;
} sort( P, P + , Cmp ); i = ;
while( P[i].Count == P[i+].Count )
{
printf("%d ", P[i].Num );
i++;
}
printf( "%d\n", P[i].Num );
} return ;
} bool Cmp( Player a, Player b )
{
if ( a.Count == b.Count )
return a.Num < b.Num;
else
return a.Count > b.Count;
}

Poj 2092 Grandpa is Famous(基数排序)的更多相关文章

  1. POJ 2092 Grandpa is Famous【水---找出现第二多的数】

    链接: http://poj.org/problem?id=2092 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#probl ...

  2. POJ 2092 Grandpa is Famous

    Grandpa is Famous Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 7153   Accepted: 3624 ...

  3. (使用STL自带的排序功能进行排序7.3.2)POJ 2092 Grandpa is Famous(结构体排序)

    /* * POJ_2092.cpp * * Created on: 2013年11月1日 * Author: Administrator */ #include <iostream> #i ...

  4. POJ 1228 - Grandpa's Estate 稳定凸包

    稳定凸包问题 要求每条边上至少有三个点,且对凸包上点数为1,2时要特判 巨坑无比,调了很长时间= = //POJ 1228 //稳定凸包问题,等价于每条边上至少有三个点,但对m = 1(点)和m = ...

  5. POJ 1228 Grandpa's Estate(凸包)

    Grandpa's Estate Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 11289   Accepted: 3117 ...

  6. poj - 1228 - Grandpa's Estate

    题意:原来一个凸多边形删去一些点后剩n个点,问这个n个点能否确定原来的凸包(1 <= 测试组数t <= 10,1 <= n <= 1000). 题目链接:http://poj. ...

  7. POJ 1228 Grandpa's Estate 凸包 唯一性

    LINK 题意:给出一个点集,问能否够构成一个稳定凸包,即加入新点后仍然不变. 思路:对凸包的唯一性判断,对任意边判断是否存在三点及三点以上共线,如果有边不满足条件则NO,注意使用水平序,这样一来共线 ...

  8. POJ 1228 Grandpa's Estate(凸包唯一性判断)

    Description Being the only living descendant of his grandfather, Kamran the Believer inherited all o ...

  9. POJ 1228 Grandpa's Estate --深入理解凸包

    题意: 判断凸包是否稳定. 解法: 稳定凸包每条边上至少有三个点. 这题就在于求凸包的细节了,求凸包有两种算法: 1.基于水平序的Andrew算法 2.基于极角序的Graham算法 两种算法都有一个类 ...

随机推荐

  1. jQuery实现页面关键字搜索

    <style type="text/css"> .highlight { background-color:yellow; } </style> <s ...

  2. Struts学习之自定义结果集

    转自:http://blog.csdn.net/hanxuemin12345/article/details/38763057 项目中我们经常遇到这样的需求——页面部分刷新,例如:添加用户,转到添加用 ...

  3. UVA 10798 - Be wary of Roses (bfs+hash)

    10798 - Be wary of Roses You've always been proud of your prize rose garden. However, some jealous f ...

  4. MySql 日期字符串类型互转

    1.data_format 日期转字符串 select date_format(Now(), '%Y-%m-%d %H:%i'); 2.str_to_date 字符串转日期 select str_to ...

  5. C——货物管理系统

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <conio.h> ...

  6. android studio 快捷笔记

    setting->editor->打勾 ctrl+Q ctrl+tab alt+回车 ctrl+shift+回车

  7. Spring Boot Logback应用日志

    e Spring Boot Logback应用日志 2015-09-08 19:57 7673人阅读 评论(0) 收藏 举报 . 分类: Spring Boot(51) . 目录(?)[+] 日志对于 ...

  8. Spring-data-redis: 分布式队列

    Redis中list数据结构,具有"双端队列"的特性,同时redis具有持久数据的能力,因此redis实现分布式队列是非常安全可靠的.它类似于JMS中的"Queue&qu ...

  9. 导出Ext.grid.Panel到excel

    1.客户端定义,基本的想法是form提交表格头定义,数据,以json方式传输 Ext.grid.Panel.addMembers({ exportExcel:function(options){ if ...

  10. 查看LINUX系统版本和硬件信息

    查看发行版本 # cat /etc/issue Red Hat Enterprise Linux Server release 6.2 (Santiago) 查看内核 # uname -a Linux ...