PAT 甲级 1054 The Dominant Color
https://pintia.cn/problem-sets/994805342720868352/problems/994805422639136768
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, 800x600), 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 <bits/stdc++.h>
using namespace std; int a[801][801];
map<int, int> mp; int main() {
int n, m;
scanf("%d%d", &m, &n);
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= m; j ++) {
scanf("%d", &a[i][j]);
mp[a[i][j]] ++;
}
} int zlr;
int cnt = 0;
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= m; j ++) {
if(mp[a[i][j]] > cnt) {
cnt = mp[a[i][j]];
zlr = a[i][j];
}
}
}
printf("%d\n", zlr); return 0;
}
PAT 甲级 1054 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 (20 分)(简单题)
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ...
- 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 i ...
- 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
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ...
- pat 1054 The Dominant Color(20 分)
1054 The Dominant Color(20 分) Behind the scenes in the computer's memory, color is always talked abo ...
- 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 ...
- 1054. The Dominant Color (20)
时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Behind the scenes in the compute ...
- 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 ...
随机推荐
- ubuntu系统部署python3.6.4
Ubuntu的版本为16.04,系统自带的Python版本较低,使用亲本版本3.6.4,下为安装步骤: 一.官网下载Python3.6.4版本 新建目录: sudo mkidr /usr/local/ ...
- C语言顺序队列
顺序队列是一种只能在一头进和另一头出的数据结构,所以结构体里设2个指针分别指向头部和尾部,用数组来存储数据. #define MAXSIZE 1024 typedef int elemtype; ty ...
- Python使用__slots__限制实例属性
#定义一个类Student class Student(object): __slots__ = ('name','age') #用元组(tuple)的形式绑定属性名称 s = Student() s ...
- AC自动机(简单版)(施工ing)
声明 想看加强版的戳这里(施工ing,作者正努力中)~ 先贴题目吧哎~ AC自动机加强版 洛谷 P3796 题目: 洛谷 P3808 (数据范围困了我好久 TAT) 反正涉及字符串的算法都很玄学 ...
- 实验2 Windows口令破解
实验2 Windows口令破解 实验目的 了解Windows口令破解原理 对信息安全有直观感性认识 能够运用工具实现口令破解 实验工具 LC5 实验原理 口令破解方法: 口令破解主要有两种方法:字典破 ...
- [BZOJ1185][HNOI2007]最小矩形覆盖-[凸包+旋转卡壳]
Description 传送门 Solution 感性理解一下,最小矩形一定是由一条边和凸包上的边重合的. 然后它就是模板题了..然而真的好难调,小于大于动不动就打错. Code #include&l ...
- Deep Learning 教程翻译
Deep Learning 教程翻译 非常激动地宣告,Stanford 教授 Andrew Ng 的 Deep Learning 教程,于今日,2013年4月8日,全部翻译成中文.这是中国屌丝军团,从 ...
- Fiddler 调用java webserivces
这是java写的webservice,并发布成功. 使用Fidder Get调用和POST调用 get比较简单: http://192.168.3.176:8080/AppTestService/se ...
- php-laravel中间件使用
中间件使用 1.项目目录下cmd中php artisan make:middleware adminLogin,创建中间件 2.注册中间件(\Http\kernel.php) protected $r ...
- Struts 2(一):初识Struts
[很久以前的笔记,后续继续完善] 在了解Struts 2框架之前,首先了解一下Model 1和Model 2架构,以及它们的优缺点. 1.1 Model 1架构模式 Model 1的核心是JSP文件, ...