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 ...
随机推荐
- 剑指offer-面试题34-二叉树中和为某一值的路径-二叉树遍历
/* 题目: 输入一颗二叉树和一个整数,打印从根节点到叶子节点中所有和为该整数的路径. */ /* 思路: 先序遍历,深度遍历. 从树根开始,记录路径之和,遍历到叶子节点,如果和为期望值,则输出. 回 ...
- JavaDay11
Java learning_Day11 本人学习视频用的是马士兵的,也在这里献上 <链接:https://pan.baidu.com/s/1qKNGJNh0GgvlJnitTJGqgA> ...
- Magento2 updated quote_item table - 更新quote_item 表自定义字段
/** * @param $class * @return mixed */ public function mc_get_obj($class) { return \Magento\Framewor ...
- Navicat Premium15安装与激活(破解)
Navicat premium是一款数据库管理工具,是一个可多重连线资料库的管理工具,它可以让你以单一程式同时连线到 MySQL.SQLite.Oracle 及 PostgreSQL 资料库,让管理不 ...
- B - Draw!
You still have partial information about the score during the historic football match. You are given ...
- 刷题78. Subsets
一.题目说明 题目78. Subsets,给一列整数,求所有可能的子集.题目难度是Medium! 二.我的解答 这个题目,前面做过一个类似的,相当于求闭包: 刷题22. Generate Parent ...
- JS实现登录页密码的显示和隐藏功能
在登录页经常会用到通过点击文本框的类似小眼睛图片来实现隐藏显示密码的功能,其实实现原理很简单,通过点击事件来改变input的type类型,具体过程看代码: 在没给大家分享实现代码之前,先给大家展示下效 ...
- 微信小程序-骰子游戏2
这是截图,类似与eclipse 的web 开发. 主界面可以自己编写程序. 可以压大压小等等,过年回家聚会的时候可以试试....
- 常见sql注入的类型
这里只讲解sql注入漏洞的基本类型,代码分析将放在另外一篇帖子讲解 目录 最基础的注入-union注入攻击 Boolean注入攻击-布尔盲注 报错注入攻击 时间注入攻击-时间盲注 堆叠查询注入攻击 二 ...
- 【Vue2.x笔记3】从源码看watch对象
初始化 function initWatch (vm: Component, watch: Object) { for (const key in watch) { const handler = w ...