PAT 甲级 1054 The Dominant Color (20 分)
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,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<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 分)的更多相关文章
- PAT 甲级 1054 The Dominant Color (20 分)(简单题)
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ...
- 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 ...
- PAT 甲级 1054 The Dominant Color
https://pintia.cn/problem-sets/994805342720868352/problems/994805422639136768 Behind the scenes in t ...
- 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 ...
- 【PAT甲级】1054 The Dominant Color (20 分)
题意: 输入两个正整数M和N(M<=800,N<=600),分别代表一张图片的宽度和高度,接着输入N行每行包括M个点的颜色编号,输出这张图片主导色的编号.(一张图片的主导色占据了一半以上的 ...
- PAT甲级:1152 Google Recruitment (20分)
PAT甲级:1152 Google Recruitment (20分) 题干 In July 2004, Google posted on a giant billboard along Highwa ...
- 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 ...
- PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way ...
- 1054. The Dominant Color (20)
时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Behind the scenes in the compute ...
随机推荐
- laravel 实现增 与查
//调用模型层 <?phpnamespace App;use Illuminate\Support\Facades\DB;use Illuminate\Database\Eloquent\Mod ...
- dubbo 异步回调
dubbo 异步回调的使用 业务接口: public interface HelloService { String sayHello(); void sayHi(String name); } 回调 ...
- 网络编程-day1
一. *** C/S架构:客户端(client)/服务端(server)架构, B/S架构:浏览器(browser) / 服务端(server)架构 软件cs架构:浏览器,qq,微信,陌陌等等 硬件c ...
- Linux下如何查看tomcat是否安装、启动、文件路径、进程ID
Linux下如何查看tomcat是否安装.启动.文件路径.进程ID 在Linux系统下,Tomcat使用命令的操作! 检测是否有安装了Tomcat: rpm -qa|grep tomcat 查看Tom ...
- ES6函数的特性(箭头语法)
//ES5中的函数的定义 var fn=function(){ console.log(111); } //ES6中函数的定义 let fn=()=>{ console.log(222); } ...
- Future模式介绍及入门使用
FutureClient代码实现: package com.hjf.future; public class FutureClient { /** * 请求客户端 * @param queryStr ...
- L328 What Is Millennial Burnout?
What Is Millennial Burnout?Do you often feel stressed? Does the pace of life make you feel like you' ...
- BOM浏览器
1.window.open(url,ways) url是打开的网页地址 ways 是打开的方式 2.window.close() 3.window.navigator 浏览器用户信息 4.windo ...
- https://www.cnblogs.com/wuyepiaoxue/p/5661194.html
https://www.cnblogs.com/wuyepiaoxue/p/5661194.html
- JS的小判断
// 0 if(undefined) { console.log('1'); } else { console.log('0'); } // 0 if(null) { console.log('1') ...