时间限制
100 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area is called the dominant color. A strictly dominant color takes more than half of the total area. Now given an image of resolution M by N (for example, 800x600), you are supposed to point out the strictly dominant color.

Input Specification:

Each input file contains one test case. For each case, the first line contains 2 positive numbers: M (<=800) and N (<=600) which are the resolutions of the image. Then N lines follow, each contains M digital colors in the range [0, 224). It is guaranteed that the strictly dominant color exists for each input image. All the numbers in a line are separated by a space.

Output Specification:

For each test case, simply print the dominant color in a line.

Sample Input:

5 3
0 0 255 16777215 24
24 24 0 0 24
24 0 24 24 24

Sample Output:

24
 #include<stdio.h>
#include<map>
using namespace std;
int main()
{
int n,m;
map<int,int> mm;
scanf("%d%d",&n,&m);
for(int i = ;i<m*n;i++)
{
int tem;
scanf("%d",&tem);
++mm[tem];
} int MAX = -;
map<int,int>::iterator it;
int index;
for(it = mm.begin();it != mm.end();it ++)
{
if(it->second > MAX)
{
MAX = it ->second;
index = it ->first;
}
} printf("%d\n",index);
return ;
}

1054. The Dominant Color (20)的更多相关文章

  1. PAT 甲级 1054 The Dominant Color (20 分)(简单题)

    1054 The Dominant Color (20 分)   Behind the scenes in the computer's memory, color is always talked ...

  2. 1054 The Dominant Color (20)(20 分)

    Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of i ...

  3. PAT (Advanced Level) Practice 1054 The Dominant Color (20 分)

    Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of i ...

  4. 1054 The Dominant Color (20分)(水)

    Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of i ...

  5. PAT甲题题解-1054. The Dominant Color (20)-排序/map

    原本用map,发现超时了,后来便先用数组存储排个序,最后for一遍统计每种颜色出现的次数(每种颜色的首位索引相减+1),找出最多的即可. #include <iostream> #incl ...

  6. PAT (Advanced Level) 1054. The Dominant Color (20)

    简单题 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #inc ...

  7. 【PAT甲级】1054 The Dominant Color (20 分)

    题意: 输入两个正整数M和N(M<=800,N<=600),分别代表一张图片的宽度和高度,接着输入N行每行包括M个点的颜色编号,输出这张图片主导色的编号.(一张图片的主导色占据了一半以上的 ...

  8. PAT 1054 The Dominant Color[简单][运行超时的问题]

    1054 The Dominant Color (20)(20 分) Behind the scenes in the computer's memory, color is always talke ...

  9. PAT 甲级 1054 The Dominant Color (20 分)

    1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ab ...

随机推荐

  1. Visual studio 2012 添加 GitHub

    文件-新建项目

  2. sql 自定义函数--十进制转二进制

    随笔记忆: if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DECTOBIN]') and xtype in ...

  3. poj 3155 最大密度子图

    思路: 这个还是看的胡伯涛的论文<最小割在信息学竞赛中的应用>.是将最大密度子图问题转化为了01分数规划和最小割问题. 直接上代码: #include <iostream> # ...

  4. Activity保持关闭不销毁

    activity按back键 消失但是不销毁的实现 重新定义finish()方法: @Override    public void finish() {        // TODO Auto-ge ...

  5. 转:Nginx+ffmpeg的HLS开源服务器搭建配置及开发详解

    转:http://itindex.net/detail/51186-nginx-ffmpeg-hls 本文概述: 至目前为止,HLS 是移动平台上非常重要并十分流行的流媒体传输协议.做移动平台的流媒体 ...

  6. Windows 7 IE11 F12 不能正常使用

    打开任意网站,按下F12,或者右键鼠标,按L键.出现上面的图的情况!解决办法如下:需要安装下面的补丁(KB3008923) 32位系统:http://www.microsoft.com/en-us/d ...

  7. Web前端学习笔记2

    一.开发工具sublime的常用快捷键. 1.                     快捷键                        功能 ctrl+shift+D 快速复制 ctrl+L 快 ...

  8. HTTP - 首部

    首部类型 首部类型 说明  通用首部   客户端和服务器都可以使用的通用首部.可以在客户端.服务器和其他应用程序之间提供一些有用的通用首部.  请求首部   请求首部时请求报文特有的.它们为服务器提供 ...

  9. JavaScript设置cookie

    在做网站的时候会用到JS操作cookie,现在写下来,算是对自己工作的一次小小总结,后面用到的时候就不用再写一遍了,高手就不用看了. /* 添加cookie 参数:cookie名,cookie值,过期 ...

  10. java开发:分享一下MemCached的使用

    在项目开发中,有些不经常修改的数据,我们通常都会选择使用缓存.其中一种方式,就是memcached. windows系统中,我们需要下载并安装memcached. 地址如:D:\memcached\m ...