【PAT甲级】1054 The Dominant Color (20 分)
题意:
输入两个正整数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 分)的更多相关文章
- PAT 甲级 1054 The Dominant Color (20 分)(简单题)
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 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甲级: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 ...
- 1054. The Dominant Color (20)
时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Behind the scenes in the compute ...
随机推荐
- STL之pair类型
C++ pair 类型 ---心怀虔诚,细细欣赏! 编程实践: Practice:编写程序读入一系列string和int型数据,将每一组存储在一个pair对象中,然后将这些pair对象存储在vecto ...
- intellij手动创建Mybatis遇到java.io.IOException: Could not find resource mybatis.xml
将配置文件夹设置成resources即可
- 百炼OJ - 1004 - 财务管理
题目链接:http://bailian.openjudge.cn/practice/1004/ 思路 求和取平均... #include <stdio.h> int main() { fl ...
- Swagger-ui接口文档
参考地址 https://github.com/swagger-api/swagger-core/wiki/Annotations-1.5.X#quick-annotation-overview ...
- Python六剑客
1.切片 切片:截取可迭代对象的部分内容(list,tuple,dict,set,str) 2.列表解析式 列表解析式可以快速的生成一个列表 不带if条件的: 格式:[expression for i ...
- js实现页面下拉后展示导航,以及点击导航自动滑动到相关页面
//监控,下拉750px后展示导航 $(window).scroll(function(){ var $this = $(this); var targetTop = $(this).scrollTo ...
- win7安装composer(PHPStudy环境)
好句没写博客园了,因为现在的公司就是写代码啥的,没有什么新的东西,但是光写代码也学到不少东西,因为本身太菜了,最近让做一个pdf表单的功能,首先得安装php-pdftk,看GitHub里面用compo ...
- 【转】解决jenkins自动杀掉衍生进程
在执行 shell输入框中加入BUILD_ID=dontKillMe ,即可防止jenkins杀死启动的进程 export BUILD_ID=dontKillMe PROJECT_LOCATION=& ...
- Git - git bash 在 windows 下创建软连接
1. 概述 使用 git bash 在 windows 下创建软连接 或者叫 快捷方式 感谢 Tony 老师的帮助 Tony 的技术笔记 Windows 使用 ln -s 创建软链接 2. 问题 需求 ...
- Linq Group by获取数量和数据
主表: public partial class Activity { [Key] public int pkActivity { get; set; } public int fkEmployee ...