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 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, 800×600), 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<iostream>

 using namespace std;

 int main()
{
int M,N,color = -,num = ,temp; cin>>M>>N; int motal = M*N; for(int i=;i<motal;++i)
{
cin>>temp; if(color != temp && num > )
{
color = temp;
--num;
}
else if(color != temp && num == )
color = temp;
else
++num;
} cout<<color<<endl; return ;
}

PAT 甲级 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. 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 ...

  3. PAT 甲级 1054 The Dominant Color

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

  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 分)

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

  6. PAT甲级:1152 Google Recruitment (20分)

    PAT甲级:1152 Google Recruitment (20分) 题干 In July 2004, Google posted on a giant billboard along Highwa ...

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

  8. PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)

    1027 Colors in Mars (20 分)   People in Mars represent the colors in their computers in a similar way ...

  9. 1054. The Dominant Color (20)

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

随机推荐

  1. 『TensorFlow』网络操作API_中_损失函数及分类器

    一.误差值 度量两个张量或者一个张量和零之间的损失误差,这个可用于在一个回归任务或者用于正则的目的(权重衰减). l2_loss tf.nn.l2_loss(t, name=None) 解释:这个函数 ...

  2. RABC --权限控制解读

    一.基于RBAC的概念介绍 1.RBAC(Role-Based Access Control )基于角色的访问控制. 2.RBAC认为权限的过程可以抽象概括为:判断[Who是否可以对What进行How ...

  3. 2015-10-15 css3

    图片模糊效果 <img id ="img1" src="image/免费学PS.jpg" style="-webkit-filter: blur ...

  4. linux如何让一个程序崩溃后自动重启

    思路:  写一个脚本 监控程序的运行状态  没有运行启动运行 已运行不做操作. 如果在控制台启动脚本 注意必须  nohup sh xxx.sh & while true do ps -ef ...

  5. Docker(一) 安装Docker

    1.在 Ubuntu上 安装 docker $ sudo apt-get install curl $ curl -fsSL get.docker.com -o get-docker.sh $ sud ...

  6. day050 django第一天 自定义框架

    1.简单的web框架 1. 创建一个简单的python文件: import socket sever=socket.socket() sever.bind(('127.0.0.1',8001)) se ...

  7. Java删除文件夹和其子文件、文件的拷贝和剪切

     1.递归删除目录下的所有文件及子目录下所有文件 //递归删除目录下的所有文件及子目录下所有文件 public static boolean deleteDir(File dir) { if (dir ...

  8. leetcode python 009

    ##懒得自己做 ##  验证回文数字int0=63435435print(int(str(int0)[::-1])==int)

  9. like contains

    like :   %/%  = *****/**** contains:     abc    = 字符串中含有  abc

  10. react native 环境报错

    按照react native中文网的文档安装 1.brew 管理软件 2.node 在终端启动工程后就报下面这个错误 这个错误是在RN在第一次配置环境启动一个工程的时候 ,在这过程中下载的缓存文件不完 ...