PAT甲级——A1054 The Dominant Color
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 Mby N (for example, 8), 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 (≤) and N (≤) which are the resolutions of the image. Then N lines follow, each contains M digital colors in the range [0). 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>
#include <vector>
#include <unordered_map> using namespace std; int main()
{
int M, N;
cin >> M >> N;
unordered_map<int, int>res;
vector<vector<int>>data(M, vector<int>(N, ));
for (int i = ; i < N; ++i)
{
for (int j = ; j < M; ++j)
{
int a;
cin >> a;
res[a]++;
if (res[a] > M*N / )
{
cout << a << endl;
break;
}
}
}
return ; }
PAT甲级——A1054 The Dominant Color的更多相关文章
- PAT 甲级 1054 The Dominant Color (20 分)
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ab ...
- PAT 甲级 1054 The Dominant Color
https://pintia.cn/problem-sets/994805342720868352/problems/994805422639136768 Behind the scenes in t ...
- PAT 甲级 1054 The Dominant Color (20 分)(简单题)
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ...
- A1054. The Dominant Color
Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of i ...
- 【算法笔记】A1054 The Dominant Color
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ...
- 【PAT甲级】1045 Favorite Color Stripe (30 分)(DP)
题意: 输入一个正整数N(<=200),代表颜色总数,接下来输入一个正整数M(<=200),代表喜爱的颜色数量,接着输入M个正整数表示喜爱颜色的编号(同一颜色不会出现两次),接下来输入一个 ...
- PAT 1054 The Dominant Color[简单][运行超时的问题]
1054 The Dominant Color (20)(20 分) Behind the scenes in the computer's memory, color is always talke ...
- PAT甲级1045. Favorite Color Stripe
PAT甲级1045. Favorite Color Stripe 题意: 伊娃正在试图让自己的颜色条纹从一个给定的.她希望通过剪掉那些不必要的部分,将其余的部分缝合在一起,形成她最喜欢的颜色条纹,以保 ...
- PAT 1054 The Dominant Color
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ...
随机推荐
- C# GZipStream 压缩 解压
关于GZipStream压缩解压,网上找了很多资料,完整的不多,要么是针对字符串压缩解压缩的,要么只实现了针对单个文件的压缩解压缩,还有的不支持子文件夹的压缩,实用性都不是很大. 以下整理了压缩解压缩 ...
- redis可视化客户端工具TreeNMS
TreeNMS是一款redis,Memcache可视化客户端工具,采用JAVA开发,实现基于WEB方式对Redis, Memcached数据库进行管理.维护. 功能包括:状态参数监控,NoSQL数据库 ...
- Java-Maven-pom.xml-project-repositories:repositories
ylbtech-Java-Maven-pom.xml-project-repositories:repositories <!--发现依赖和扩展的远程仓库列表. --> 1. platfo ...
- 图解 5 种 Join 连接及实战案例!(inner/ left/ right/ full/ cross)
Join 连接在日常开发用得比较多,但大家都搞清楚了它们的使用区别吗??一文带你上车~~ 内连接 inner join 内连接是基于连接谓词将俩张表(如A和B)的列组合到一起产生新的结果表,在表中存在 ...
- java-day04
IntelliJ快捷键 导入包 alt + enter 删除光标所在行 ctrl + y 复制光标所在行 ctrl + d 格式代码 ctrl + alt + l 单行注释 ctrl + / 多行注释 ...
- c# 多态实现_虚方法
实现方法: 虚方法, 抽象类, 接口 1.虚方法 将父类的方法标记为虚方法,使用关键字virtual,这个方法可以被子类重新写一遍. 在父类的方法前面加上一个virtual,在子类的方法前面加上一个o ...
- img属性src的特点
img属性src的特点: src=“图片地址” 成功则加载图片,失败则显示alt文字和断裂的图片 src="" 则不加载,不显示alt文字和断裂的图片 因此当图片加载失败后,$(& ...
- 导入excel并进行数据提取
/** * @description: 导入excel并进行数据提取 * @param {type} * @return: */ Vue.prototype.$importExcel = functi ...
- 【JZOJ2679】跨时代
description 钟逆时针而绕,恶物狰狞的倾巢,我谦卑安静地于城堡下的晚祷,压抑远古流窜的蛮荒暗号,而管风琴键高傲的说,那只是在徒劳.我的乐器在环绕,时代无法淘汰我霸气的皇朝. 你无法预言,因为 ...
- html选择器[获取兄弟(同级元素)]
1.html <div class="col-md-5"> <h4 class="m-t-md" id="dwzh"> ...