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 ...
随机推荐
- 打造springboot高性能服务器(spring reactor的使用)
推荐:https://www.cnblogs.com/ivaneye/p/5731432.htmlpom依赖: <dependency> <groupId>org.spring ...
- PAT 1077 Kuchiguse
1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Person ...
- OpenStack 部署步骤详解(mitaka/ocata/一键部署)
正文 OpenStack作为一个由NASA(美国国家航空航天局)和Rackspace合作研发并发起的,开放源代码项目的云计算管理平台项目.具体知识我会在后面文章中做出介绍,本章主要按步骤给大家演示在C ...
- Vue入门笔记(一)--基础部分
github地址:https://github.com/iTao9354/basicVue(demo01-28) 一.初识Vue 使用双大括号{{message}}将数据渲染进DOM中. 可 ...
- kaptcha验证码插件使用与参数
kaptcha使用1 kaptcha使用2 kaptcha使用3 kaptcha参数说明
- SQL-44 将id=5以及emp_no=10001的行数据替换成id=5以及emp_no=10005,其他数据保持不变,使用replace实现。
题目描述 将id=5以及emp_no=10001的行数据替换成id=5以及emp_no=10005,其他数据保持不变,使用replace实现.CREATE TABLE IF NOT EXISTS ti ...
- oracel sql分组求和过滤条件
- like contains
like : %/% = *****/**** contains: abc = 字符串中含有 abc
- 使用mybatis generator插件,自动生成dao、dto、mapper等文件
mybatis generator 介绍 mybatis generator中文文档http://mbg.cndocs.tk/ MyBatis Generator (MBG) 是一个Mybatis的代 ...
- Linux 驱动——从宏观上掌握基本框架
一.一个简单的驱动程序实例 led_drv.c 驱动文件: #include <linux/module.h>#include <linux/kernel.h>#include ...