题意:

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

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int m,n;
cin>>m>>n;
int cnt=;
for(int i=;i<=n;++i)
for(int j=;j<=m;++j)
cin>>a[++cnt];
sort(a+,a++cnt);
if(m==&&n==){
cout<<a[];
return ;
}
int tamp=,ans=;
for(int i=;i<=cnt;++i){
if(a[i]==a[i-])
++tamp;
else
tamp=;
if(tamp>cnt/){
cout<<a[i];
return ;
}
}
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 ...

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

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

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

  4. PAT 甲级 1054 The Dominant Color

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

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

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

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

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

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

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

  9. 1054. The Dominant Color (20)

    时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Behind the scenes in the compute ...

随机推荐

  1. STA之PVT

    在STA星球,用library PVT.RC corner跟OCV来模拟这些不可控的随机因素.在每个工艺结点,通过大量的建模跟实测,针对每个具体的工艺,foundary厂都会提供一张推荐的timing ...

  2. java1.8特性

    java1.8特性 1.lambda表达式 Java8为集合类引入了另一个重要概念:流(stream).一个流通常以一个集合类实例为其数据源,然后在其上定义各种操作 例如 .filter .forEa ...

  3. docker里面安装sqlserver2017

    首先要注意,docker一般不做数据持久化容器.如果非要安装可以参考微软官方教程: https://docs.microsoft.com/zh-cn/sql/linux/quickstart-inst ...

  4. Demo:基于 Flink SQL 构建流式应用

    Flink 1.10.0 于近期刚发布,释放了许多令人激动的新特性.尤其是 Flink SQL 模块,发展速度非常快,因此本文特意从实践的角度出发,带领大家一起探索使用 Flink SQL 如何快速构 ...

  5. 1.3 使用jmeter进行http接口测试

    来源: http://www.cnblogs.com/alisapan/p/6150309.html 此篇纯是搬运记载..   一.测试需求描述 1. 本次测试的接口为http服务端接口 2. 接口的 ...

  6. 拓扑排序(poj 1094)

    前置知识:拓扑排序 详细注释都在代码里 //该题题意明确,就是给定一组字母的大小关系判断他们是否能组成唯一的拓扑序列. //是典型的拓扑排序,但输出格式上确有三种形式: // 1.该字母序列有序,并依 ...

  7. Atcoder Beginner Contest151E(排列组合)

    排列组合 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; ; ]; long lo ...

  8. nginx配置访问密码,输入用户名和密码才能访问

    1. 安装 htpasswd 工具 yum install httpd-tools -y 设置用户名和密码,并把用户名.密码保存到指定文件中: [sandu@bogon conf]$ sudo mkd ...

  9. CSS学习(11)常规流

    盒模型:规定单个盒子的规则 视觉格式化模型(布局规则):页面中多个盒子的排列规则 三种方式: 1.常规流 2.浮动 3.定位 常规流布局 常规流   也可以叫做   文档流.普通文档流.常规文档流 所 ...

  10. 每日扫盲(四):java之Netty原理和使用

    转自:https://www.jdon.com/concurrent/netty.html Netty是一个高性能 事件驱动的异步的非堵塞的IO(NIO)框架,用于建立TCP等底层的连接,基于Nett ...