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, 2^24^). 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<cstdio>
int main(){
int m,n,col,ans= -,count = ;
scanf("%d%d",&m,&n);
for(int i = ; i < m; i++){
for(int i = ; i < n; i++){
scanf("%d",&col);
if(count == ){
ans = col;
count = ;
}
else{
if(ans == col) count++;
else count--;
}
}
}
printf("%d",ans);
return ;
}
#include<cstdio>
#include<map>
using namespace std;
int main(){
int n,m,col;
map<int,int> count;
scanf("%d%d",&m,&n);
for(int i = ; i < m; i++){
for(int j= ; j < n; j++){
scanf("%d",&col);
if(count.find(col)!=count.end()) count[col]++;
else count[col] = ;
}
}
int k = , max = ;
for(map<int,int>::iterator it=count.begin(); it != count.end(); it++){
if(it -> second > max){
k = it -> first;
max = it -> second;
}
}
printf("%d",k);
return ;
}

1054 The Dominant Color (20)(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 ab ...

  2. pat 1054 The Dominant Color(20 分)

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

  3. PAT 1054 The Dominant Color

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

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

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

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

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

  6. 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 ...

  7. 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 ...

  8. 1054. The Dominant Color (20)

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

  9. PAT 甲级 1054 The Dominant Color

    https://pintia.cn/problem-sets/994805342720868352/problems/994805422639136768 Behind the scenes in t ...

随机推荐

  1. 记一次git merge 事故

    最近发生在自己身上的一件矬事儿,一不小心把matser上别人的代码给冲掉了,事后追溯了下原因. 1.准备三个分支,分别从master拉取 realease/v1.0分支 和 realease/bugf ...

  2. java之struts2之ServletAPI

    在之前的学习中struts2已经可以处理大部分问题了.但是如果要将用户登录数据存入session中,可以有两种方式开存入ServletAPI. 一种解耦合方式,一种耦合方式. 1. 解耦合方式 解耦合 ...

  3. asBroadcastStream

    StreamSubscription sc = StreamSubscription(); Stream s = Stream(); sc.addStream(s); var bs = sc.stre ...

  4. 阿里企业邮箱smtp设置

    阿里的邮箱没有SMTP授权码信息 SMTP服务器:smtp.mxhichina.com

  5. javascript 区域外事件捕捉setCapture

    今天遇到了这个方法,便去度娘了解了下 函数功能:该函数在属于当前线程的指定窗口里设置鼠标捕获.一旦窗口捕获了鼠标,所有鼠标输入都针对该窗口,无论光标是否在窗口的边界内.同一时刻只能有一个窗口捕获鼠标. ...

  6. [AIR] NativeExtension在IOS下的开发实例 --- IOS项目的创建 (一)

    来源:http://bbs.9ria.com/thread-102037-1-1.html 最近看到本版块的很多关于NativeExtension的应用.但是都是在Android下面的应用.也有很多朋 ...

  7. 广联达C++面经(一站式西安) - 2019秋招

    9月7号通知在广联达西安面试,早上在高新面完中兴一面就赶忙坐地铁倒公交去面试了.  一面(大概30-40min) 刚去签了一个到,就带我去面试了,在一个小型会议室,面试我的是一个女面试官(第一次碰见女 ...

  8. Laravel5.6---从头做一个项目web

    简介:类似论坛的项目,纯web,响应式,主要包含登录注册.支付.评论.富文本.文章列.个人中心等 目录: 1.初始化项目 ======================================= ...

  9. Anaconda-Jupyter notebook 如何安装 nbextensions

    系统环境:windows 安装过程中,再次遇到了一地鸡毛,经过不断查询方法,发现前辈大牛们好棒棒! Step1:确定是已经安装好anaconda Step2:要在anaconda prompt模式下运 ...

  10. 3D中OBJ文件格式详解

    常见到的*.obj文件有两种:第一种是基于COFF(Common Object File Format)格式的OBJ文件(也称目标文件),这种格式用于编译应用程序:第二种是Alias|Wavefron ...