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. 利用ime-mode设置文本框只能输入正整数

    html: <input type="text" id="packageratio"style="ime-mode: disabled;&quo ...

  2. showModalDialog的使用方法

    基本介绍: showModalDialog()         (IE 4+ 支持) showModelessDialog()      (IE 5+ 支持) window.showModalDial ...

  3. winform实现图片的滑动效果

    使用winform实现图片的滑动效果(类似网站首页图片滑动切换效果),结果实现了,但是效果其实不是很理想.也许有更好的方法.         Timer timerSlide = null; //当前 ...

  4. OC 组合实现多继承

    OC无法完全先C++使用多继承,但可以采用组合的模式来代替继承模式.(协议实现)实现多继承的代码:举例现在ClassC需要继承ClassA中methodA.ClassB中methodB,具体的代码为: ...

  5. Windows10 安装VirtualBox出现2502、2503错误解决方法

    先来到VirtualBox的下载位置,如图,笔者位置在D:/vb文件夹下   下载目录 然后按住win+R(win就是左下角ctrl和alt之间那个键),输入cmd,然后回车 如果在C盘的话,就直接c ...

  6. 从学习“单例模式”学到的Java知识:双重检查锁和延迟初始化

    一切真是有缘,上午刚刚看完单例模式,还在为其中的代码块同步而兴奋,下午就遇见这篇文章:双重检查锁定与延迟初始化.我一看,文章开头语出惊人,说这是一种错误的优化,我说,难道上午学的东西下午就过时了吗?仔 ...

  7. 【kafka】安装部署kafka集群(kafka版本:kafka_2.12-2.3.0)

    3.2.1 下载kafka并安装kafka_2.12-2.3.0.tgz tar -zxvf kafka_2.12-2.3.0.tgz 3.2.2 配置kafka集群 在config/server.p ...

  8. 基于NFS的PV动态供给(StorageClass)

    一.简介 PersistentVolume(PV)是指由集群管理员配置提供的某存储系统上的段存储空间,它是对底层共享存储的抽象,将共享存储作为种可由用户申请使的资源,实现了“存储消费”机制.通过存储插 ...

  9. Python 网络爬虫的常用库汇总

    爬虫的编程语言有不少,但 Python 绝对是其中的主流之一.下面就为大家介绍下 Python 在编写网络爬虫常常用到的一些库. 请求库:实现 HTTP 请求操作 urllib:一系列用于操作URL的 ...

  10. django框架介绍安装-自写框架

    原文链接:https://www.cnblogs.com/maple-shaw/p/8862330.html Web框架本质 我们可以这样理解:所有的Web应用本质上就是一个socket服务端,而用户 ...