PAT 甲级 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 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
题意:
数数哪个颜色过半
AC代码:
#include<iostream>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int a[];
int main(){
int n,m;
cin>>n>>m;
int last=-;
for(int i=;i<=m;i++){
for(int j=;j<=n;j++){
int x;
cin>>x;
a[x]++;
if(a[x]>n*m/){
last=x;
} }
}
cout<<last;
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 ab ...
- 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 甲级 1144 The Missing Number (20 分)(简单,最后一个测试点没过由于开的数组没必要大于N)
1144 The Missing Number (20 分) Given N integers, you are supposed to find the smallest positive in ...
- 【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 ...
随机推荐
- re模块及其用法
一.re模块下的常用方法 首先在使用re模块之前,需要引入re模块 import re 1.与查找相关的: 1.findall 返回列表,找到所有的匹配项 ret = re.findall(" ...
- 轻院校赛-zzuli 2266: number【用每位的二进制的幂的和来进行hash(映射)处理】
zzuli 2266: number 大致题意: 给定n,问有多少数对<x, y>满足: x, y∈[1, n], x < y x, y中出现的[0, 9] ...
- canvas圆形进度条(逆时针)
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8& ...
- python 操作 MySQL 即相关问题
导入pymysql import pymysql # 创建connect()对象 conn = pymysql.connect( host = '127.0.0.1', port = 3306, us ...
- js手机点击图片放大
点击每个图片获取到对应的img的url链接,再把链接给一个空img以此来实现 最终效果:
- vue文件夹上传源码
一. 功能性需求与非功能性需求 要求操作便利,一次选择多个文件和文件夹进行上传:支持PC端全平台操作系统,Windows,Linux,Mac 支持文件和文件夹的批量下载,断点续传.刷新页面后继续传输. ...
- xlrd/xlwt
操作 xls格式的excel文件 读模块 xlrd import xlrd 打开文件 wb= xlrd.open_workbook('xxxx.xls') 获取excel中的表 ws= wb.shee ...
- linux系列(四):mkdir命令
1.命令格式: mkdir [选项] 目录名 2.命令功能: 通过 mkdir 命令可以实现在指定位置创建以 DirName(指定的文件名)命名的文件夹或目录.要创建文件夹或目录的用户必须对所创建的文 ...
- 数据结构实验之图论二:图的深度遍历(SDUT 2107)(简单DFS)
题解:图的深度遍历就是顺着一个最初的结点开始,把与它相邻的结点都找到,也就是一直往下搜索直到尽头,然后在顺次找其他的结点. #include <bits/stdc++.h> using n ...
- 【原创】go语言学习(八)切片
目录: 切片定义 切片基本操作 切片传参 make和new的区别 切片定义 1. 切片是基于数组类型做的一层封装.它非常灵活,可以自动扩容. var a []int //定义一个int类型的空切⽚ 2 ...