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, 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
#define _CRT_SECURE_NO_WARNINGS
#include <climits>
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std; int main()
{
map<string, int> Map;
int N, M;
cin >> N >> M;
for (int i = ; i < M; i++)
{
for (int j = ; j < N; j++)
{
string s;
cin >> s;
Map[s]++;
}
}
int Max = ;
string s;
for(auto it:Map)
if (it.second > Max)
{
Max = it.second;
s = it.first;
}
cout << s;
}
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 (20 分)
题意: 输入两个正整数M和N(M<=800,N<=600),分别代表一张图片的宽度和高度,接着输入N行每行包括M个点的颜色编号,输出这张图片主导色的编号.(一张图片的主导色占据了一半以上的 ...
- 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 ...
- 1054. The Dominant Color (20)
时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Behind the scenes in the compute ...
- PAT甲题题解-1054. The Dominant Color (20)-排序/map
原本用map,发现超时了,后来便先用数组存储排个序,最后for一遍统计每种颜色出现的次数(每种颜色的首位索引相减+1),找出最多的即可. #include <iostream> #incl ...
- PAT (Advanced Level) 1054. The Dominant Color (20)
简单题 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #inc ...
- PAT 1054 The Dominant Color[简单][运行超时的问题]
1054 The Dominant Color (20)(20 分) Behind the scenes in the computer's memory, color is always talke ...
- PAT 甲级 1054 The Dominant Color (20 分)
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ab ...
随机推荐
- seo搜索优化教程13-SEO搜索引擎站点收录
为了使大家更方便的了解及学习网络营销推广.seo搜索优化,星辉科技强势推出seo搜索优化教程.此为seo教程第13课 想要用户能够在搜索引擎中通过关键词搜索到您的页面信息,首先要做的是让搜索引擎收录您 ...
- openwrt 外挂usb 网卡 RTL8188CU 及添加 RT5572 kernel支持
RT5572 原来叫 Ralink雷凌 现在被 MTK 收购了,淘宝上买的很便宜50块邮,2.4 5G 双频.在 win10 上插了试试,果然是支持 5G.这上面写着 飞荣 是什么牌子,有知道的和我说 ...
- Flutter json 2 model with Built Value
Flutter json 2 model with Built Value Flutter中json转换model, 除了手动转之外, 就是利用第三方库做一些代码生成. 流行的库有: json_ser ...
- 关于SDL的一些坑:找不到WinMain,不显示控制台,添加链接库等
目录: 用CMake构建SDL时报错 Gcc添加链接库 Gcc找不到入口(WinMain) 让SDL启动时不带控制台窗口 用CMake构建SDL时报错 root@ubuntu:~/SDL# cmake ...
- Linux 文件系统及 ext2 文件系统
linux 支持的文件系统类型 Ext2: 有点像 UNIX 文件系统.有 blocks,inodes,directories 的概念. Ext3: Ext2 的加强版,添加了日志 ...
- 聊聊order by rand()
总结写在前面: 1. 不建议直接使用order by rand(),原因是执行代价比较大 2. 介绍了内存临时表,对于内存临时表,由于回表不需要访问磁盘,所以往往是用rowid排序,可以减少参与排序字 ...
- @on-row-click="$emit('on-row-click', arguments[0], arguments[1])" 行内返回事件的一种写法
@on-row-click="$emit('on-row-click', arguments[0], arguments[1])"
- Python习题集(十三)
每天一习题,提升Python不是问题!!有更简洁的写法请评论告知我! https://www.cnblogs.com/poloyy/category/1676599.html 题目 写一个函数,该函数 ...
- 安卓App自动化测试环境
一.appium安装 1.nodejs依赖 2..net framework 3.Appium桌面程序安装 3.1.安装包获取 3.2.安装过程 二.Java_ jdk安装 1.Java_jdk版本说 ...
- docker:一文学基础使用
目录 docker介绍 安装与镜像源配置 CentOS7 安装 设置镜像源 补充: 简单使用例子 基础概念 四个概念 镜像概念补充: 容器概念补充: 常用命令: 查看docker信息 镜像操作 容器操 ...