题意:

输入两个正整数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. 第二十六篇 玩转数据结构——二分搜索树(Binary Search Tree)

          1.. 二叉树 跟链表一样,二叉树也是一种动态数据结构,即,不需要在创建时指定大小. 跟链表不同的是,二叉树中的每个节点,除了要存放元素e,它还有两个指向其它节点的引用,分别用Node l ...

  2. Sass&Scss入门 选择器 混合器 导入 条件判断 迭代

    Sass 基于ruby的一种将脚本解析成CSS的脚本语言.也可以说是一种预处理语言. Sass在css的语法基础上增加了变量.嵌套.混合.继承.导入等高级功能. 使用Sass与Sass样式库(如com ...

  3. 第一struts2程序

    今天学习了第一个struts2程序 第一步建立一个java web程序 第二步 加入jar包 第三步 添加两个jsp文件 login.jsp和result.jsp文件 login.jsp 在body部 ...

  4. js jquery 页面初始化加载

    一.js 页面加载初始化方法 // 1.在body里面写初始化方法. <body onload='init()'> </body> <script type=" ...

  5. MySQL数学函数简明总结

    1. ABS(x): 返回x的绝对值 mysql> select ABS(1), ABS(-1), ABS(0); +--------+---------+--------+| ABS(1) | ...

  6. python练习:编写一个程序,检查3个变量x,y,z,输出其中最大的奇数。如果其中没有奇数,就输出一个消息进行说明。

    python练习:编写一个程序,检查3个变量x,y,z,输出其中最大的奇数.如果其中没有奇数,就输出一个消息进行说明. 笔者是只使用条件语句实行的.(if-else) 重难点:先把三个数进行由小到大的 ...

  7. JAVA 爬虫框架webmagic 初步使用Demo

    一想到做爬虫大家第一个想到的语言一定是python,毕竟python比方便,而且最近也非常的火爆,但是python有一个全局锁的概念新能有瓶颈,所以用java还是比较牛逼的, webmagic 官网 ...

  8. 6_15 给任务排序(UVa10305)<拓扑排序>

    John有n件事情要做,不幸的是这些事情并不是各自独立的,而是有相依性的.换句话说可能有某件事情一定要在另一件事情做完之后才能做.Input每组测试数据可能有好几列.第一列有2个整数n,m.(1 &l ...

  9. Django框架之ORM的相关操作(一)

    一.一般操作 from django.db import models import datetime # Create your models here. class Author(models.M ...

  10. localhost: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

    在开启hadoop时候报错:localhost: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). 此时 ssh ...