题意:

输入两个正整数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. 微信小程序 获取cookie 以及设置 cookie

    小程序开发中我们需要获取到后端给的cookie进行请求验证,但是微信并没有帮我们保存cookie,那么我们要维持会话需要自己来保存cookie,并且请求的时候加上cookie 1.获取cookie 在 ...

  2. Java+Selenium+Testng自动化测试学习(二)

    Java+Selenium+TestNG自动化测试框架整合 1.简化代码 封装一个定位元素的类,类型为ElementLocation package com.test; import org.open ...

  3. Multisim 之逻辑转换仪

    1.逻辑转换仪的作用 已知逻辑电路图 1)根据逻辑电路图转换成逻辑表达式 2)化简逻辑表达式 3)列出真值表 已知真值表 1)根据真值表转化成逻辑表达式 2)根据逻辑表达式生成逻辑电路 2.如何在Mu ...

  4. opencv:轮廓匹配

    #include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namespace st ...

  5. 【安卓逆向】ARM常见汇编指令总结

    跳转指令 B 无条件跳转 BL 带链接的无条件跳转 BX 带状态切换的无条件跳转 BLX 带链接和状态的无条件跳转 存储器与寄存器交互数据指令(核心) 存储器:主存和内存 寄存器中放的数据:可以是字符 ...

  6. 高内存 高CPU 劣质网络下的测试

    内存 先把系统的虚拟内存去掉 (右键我的电脑属性里有的.选择那个无分页文件 虚拟内存在任务管理器就不显示了), 然后机子本身内存不高,开几个网页就满了       CPU cpu可以用鲁大师测试cpu ...

  7. github,gitlab的区别

    链接:https://blog.csdn.net/Xiamen_XiaoHong/article/details/83655447 总而言之:gitlab最优

  8. vue音乐播放器

    利用vue写一个简单的音乐播放器,包括功能有歌曲搜索.歌曲播放.歌曲封面.歌曲评论.播放动画.mv播放六个功能. <template> <div class="wrap&q ...

  9. MySQL 学习(二)总体框架 & redo-log 和 bin-log 的介绍

    文章部分总结来自课程,非原创 MySQL 组织架构     下面这张图就可以解释关于 MySQL 底层的组织架构了.     上面的图可以直观地展示两个重要的东西 : 一条 SQL 的执行流程 MyS ...

  10. Spring - Spring Boot - 应用构建与运行

    概述 spring boot 应用构建 spring boot 应用运行 背景 之前的看了看 Spring 的书, 结果老懒没实践 而且后续有别的想法, 但这个始终是第一步 1. 准备 知识 java ...