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 分)(简单题)的更多相关文章

  1. PAT 甲级 1054 The Dominant Color (20 分)

    1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ab ...

  2. 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 ...

  3. PAT 甲级 1054 The Dominant Color

    https://pintia.cn/problem-sets/994805342720868352/problems/994805422639136768 Behind the scenes in t ...

  4. 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 ...

  5. PAT 甲级 1144 The Missing Number (20 分)(简单,最后一个测试点没过由于开的数组没必要大于N)

    1144 The Missing Number (20 分)   Given N integers, you are supposed to find the smallest positive in ...

  6. 【PAT甲级】1054 The Dominant Color (20 分)

    题意: 输入两个正整数M和N(M<=800,N<=600),分别代表一张图片的宽度和高度,接着输入N行每行包括M个点的颜色编号,输出这张图片主导色的编号.(一张图片的主导色占据了一半以上的 ...

  7. PAT甲级:1152 Google Recruitment (20分)

    PAT甲级:1152 Google Recruitment (20分) 题干 In July 2004, Google posted on a giant billboard along Highwa ...

  8. 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 ...

  9. PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)

    1027 Colors in Mars (20 分)   People in Mars represent the colors in their computers in a similar way ...

随机推荐

  1. python模拟双色球大乐透生成算法

    每天练习一段python代码,健康生活一辈子.晚上下班没事,打开电脑继续编写python代码!今天分享的一个是大家熟悉的双色球彩票的游戏,根据这个进行写的一个python算法,代码精简,肯定有bug, ...

  2. mac下解决中文乱码的问题

    最近在做自己的博客项目,需要在公司和家代码同步,当然代码托管到了码云上面,但是公司是win系统,家里是mac系统,奇怪的是在公司.....算了不废话了,直接正题吧. 就是代码在公司中文显示没毛病,然后 ...

  3. Web前端 --- BOM和DOM

    目录 前端基础之BOM和DOM BOM DOM 前端基础之BOM和DOM BOM是指浏览器对象模型,他使JavaScript有能力与浏览器进行对话 DOM是指文档对象模型,通过它,可以访问HTML文档 ...

  4. jquery模仿淘宝星星打分

    今天做论坛页面有星星评分功能,以下是代码.用的时候引入jquery <span> <ul class="hs_df_xx"> <li><i ...

  5. java.sql.SQLException: connection holder is null;

    一.问题来源分析 出现的错误 : Cause: java.sql.SQLException: connection holder is null; uncategorized SQLException ...

  6. 关于 js 函数参数的this

    先看一道面试题: var number = 10; function fn() { console.log(this.number); } var obj = { number: 2, show: f ...

  7. 理解 java 使用 异或 交换两数

    网上看了一些使用异或交换两数,不是很好理解.现在写一下自己的理解. 首先是 异或原则,对于任意 x: x ^ x == 0; x ^ 0 == x; 思路: 根据原则,可以得到两个公式: 求a:    ...

  8. python 根据时间戳获取秒🐱

    print("当前时间: ",time.strftime('%Y.%m.%d %H:%M:%S ',time.localtime(time.time()))) import tim ...

  9. MySQL的sql解析

    首先看一下示例语句 SELECT DISTINCT  < select_list > FROM  < left_table > < join_type > JOIN ...

  10. 关于 Win10 下使用 IETester 的问题

    真没想到,现在都用上Win10了,居然还会有使用 IETester 的需求,今天一个客户反应界面出现变形.错位的情况,于是又想到了这个老古董,去它的官网一看,果然N年没更新了! 抱着试试看的心理,下载 ...