1054 The Dominant Color
大致题意就是给出N行M列的元素,找出出现次数最多的元素并输出。
#include<iostream>
#include<unordered_map>
using namespace std; int main() {
unordered_map<int,int> mp;
int m,n;
cin>>m>>n;
for(int i = ; i < n; ++i) {
for(int j = ; j < m; ++j) {
int t;
scanf("%d",&t); //可能会超时,把cin改为scanf
mp[t]++;
}
}
int max = -,ans = ;
for(auto it = mp.begin(); it != mp.end(); ++it) {
if(max < it->second) {
max = it->second;
ans = it->first;
} }
cout<<ans;
return ;
}
1054 The Dominant Color的更多相关文章
- PAT 1054 The Dominant Color
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 1054 The Dominant Color[简单][运行超时的问题]
1054 The Dominant Color (20)(20 分) Behind the scenes in the computer's memory, color is always talke ...
- pat 1054 The Dominant Color(20 分)
1054 The Dominant Color(20 分) Behind the scenes in the computer's memory, color is always talked abo ...
- PAT 甲级 1054 The Dominant Color (20 分)(简单题)
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ...
- 1054. The Dominant Color (20)
时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Behind the scenes in the compute ...
- PAT 甲级 1054 The Dominant Color
https://pintia.cn/problem-sets/994805342720868352/problems/994805422639136768 Behind the scenes in t ...
- 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 (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 ...
- 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 ...
随机推荐
- python函数的使用
python函数的使用 制作人:全心全意 函数的定义 def 函数名(参数): 函数体 参数的使用 def 函数名(a): 函数体 函数名(5) 默认函数 def 函数名(a=5): 函数体 函数名( ...
- 我眼中的ASP.NET.MVC
MVC MVC全名 : Model View Controller ( Model-模型 View-视图 Controller-控制器)是一种经典的,经久不衰的,屹立不倒的软件设计框架.实现了业务逻 ...
- 工作中遇到的js跨域问题总结
起因:之前在做一个项目的时候有这样一个问题,127.0.0.1域名上的一个页面A.html,需要访问127.0.0.2域名上B.html页面中的一个方法.这就涉及到JS跨域访问了,通过查阅资料,得以解 ...
- 拓展lucas结论及模板
lucas及其拓展 模板题 洛谷 P4720 本文侧向结论和代码实现, 推导请转至lucas定理及其拓展的推导 https://blog.csdn.net/yuyilahanbao/article/d ...
- netty 4.x用户使用指南
引言 问题 现在我们使用通用的应用程序或库来相互通信.例如,我们经常使用HTTP客户机从web服务器检索信息,并通过web服务调用远程过程调用.然而,通用协议或其实现有时不能很好地进行扩展.这就像我们 ...
- LOJ6287 诗歌
题意 给定一个排列,问是否存在\(\forall a,b,a\neq b\)满足\(2|(a+b)\)且\(\frac{a+b}{2}\)在\(a,b\)间 做法 枚举中点\(a\),即需要存在类似\ ...
- netty 的事件驱动
netty 是事件驱动的,这里面有两个含义,一是 netty 接收到 socket 数据后,会产生事件,事件在 pipeline 上传播,二是事件由特定的线程池处理. NioEventLoop 轮询网 ...
- C#中类的编程规范
C#中类的编程规范,或许这是一个好习惯. using System; using System.Collections.Generic; using System.Linq; using System ...
- 数据库中查出来的时间多8小时&查询数据正常展示少8小时
将serverTimezone的配置改为Asia/Shanghaiurl: jdbc:mysql://127.0.0.1:3306/bfc?useUnicode=true&characterE ...
- LAMP环境搭建与配置(3)
PHP配置 查看PHP配置文件的位置 # /usr/local/php/bin/php -i |grep -i "loaded configuration file" ...