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. 『PyTorch x TensorFlow』第六弹_从最小二乘法看自动求导

    TensoFlow自动求导机制 『TensorFlow』第二弹_线性拟合&神经网络拟合_恰是故人归 下面做了三个简单尝试, 利用包含gradients.assign等tf函数直接构建图进行自动 ...

  2. [hdu P4081] Qin Shi Huang’s National Road System

    [hdu P4081] Qin Shi Huang’s National Road System Time Limit: 2000/1000 MS (Java/Others)    Memory Li ...

  3. WIFI 万能钥匙万玉权:团队之中要有跨三界之外的“闲人” [转]

      在团队规模较小时,很多事情都可以变得特别简单.比如架构的选择,大部分情况下,最初的架构越简单越好,随着业务的演进,架构才不断完善. 连尚网络经历了从几人到上百人的管理过程,其自主创新研发的产品 W ...

  4. windows线程池

    #define _WIN32_DCOM #include <SDKDDKVer.h> #include <direct.h> #include <thr/threads. ...

  5. 3D打印GCODE文件学习(二)

    大家可以自己实践一下,那么怎么打开GCODE呢?很简单,只要在桌面上创建一个word文档,然后把“.”后面的docx改成GCODE,它会跳出一个是否更改的框,点击是就行了,然后右键,点击Edit wi ...

  6. H5离线缓存技术

      HTML5提供了很多新的功能以及相应的接口,离线存储就是其中的一个,离线存储可以将站点的一些文件存储在本地,在没有网络的时候还是可以访问到以缓存的对应的站点页面,其中这些文件可以包括html,js ...

  7. vue学习笔记 - 篇2

    1.借助Vue.extend()方法创建组件 注意点 var Aaa = Vue.extend({ template: "<h1>这是标题</h1>" }) ...

  8. 18-09-20 关于Excel 表格重复问题解决示例

    代码实现:b=a.drop_duplicates(subset=None, keep='first', inplace=False) Excel 去除重复项 在测试过程中,会经常遇到多张表格筛选比对的 ...

  9. javascript 统计字符串中每个字符出现的次数

    var str = "abdcadfasfdbadfafdasdfasyweroweurowqrewqrwqrebwqrewqrejwq;;"; // console.log(nu ...

  10. iOS 弹幕制作

    离职的最后一天,在公司学习下弹幕的制作.基于OC. 主要思路: 1.首先建一个弹幕类BulletView,基于UIView,然后在该类上写个UIlabel,用于放置弹幕文字,然后前端放置一个UIIma ...