时间限制
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. WdatePicker时间控件联动选择

    $("#txtStartTime").bind("click focus", function () { var endtimeTf = $dp.$('txtE ...

  2. JS的replace方法【转】

    replace() 方法的参数 replacement 可以是函数而不是字符串.在这种情况下,每个匹配都调用该函数,它返回的字符串将作为替换文本使用.该函数的第一个参数是匹配模式的字符串.接下来的参数 ...

  3. AES 加解密

    // // NSData+AES.h // Smile // // Created by 蒲晓涛 on 12-11-24. // Copyright (c) 2012年 BOX. All rights ...

  4. 为Google Reader守夜。。。

    Google的阅读器快要关闭了... 立刻截图留恋呢,以后就没机会了. 唉,真是令人惋惜. 虽然我接触Google Reader还不到一年,但是我已经习惯当连上WiFi时马上更新一下手机上的gRead ...

  5. Windows Embedded CE 6.0开发环境的搭建

    最近开始在学习嵌入式,在这里首先得安装Windows Embedded CE 6.0,其中遇到了很多问题,电脑的系统以及相关配置都会在安装过程中受到影响,因此笔者就安装中的问题以及环境搭建来介绍一下. ...

  6. Git CMD - checkout: Switch branches or restore working tree files

    命令格式 git checkout [-q] [-f] [-m] [<branch>] git checkout [-q] [-f] [-m] --detach [<branch&g ...

  7. Javascript之spry菜单栏

    我没有添加任何东西,这是Dreamweaver原汁原味用spry创建的菜单栏,以此来学习菜单导航,哈哈. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTM ...

  8. 安装和启动mongodb数据库

    参考链接:http://www.fkblog.org/blog569 参考链接:http://www.cnblogs.com/linjiqin/p/3192159.html

  9. html 文件动态加载.PDI 流程图

    1 //javascript脚本 <script> window.onload = function () { var aid = document.getElementById(&quo ...

  10. 【整理修订】Android.mk详解

    Android.mk详解 1. Android.mk 的应用范围 Android.mk文件是GNU Makefile的一小部分,它用来对Android程序进行编译. 一个Android.mk文件可以编 ...