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 ...
随机推荐
- 学习使用add()()()迭代调用,柯里化处理
将多个参数的函数,转换成单参数函数链 以add()()()举例 function add(){ 使用数组保存参数 let _args = Array.prototype.slice.call(argu ...
- 根据ip列表模拟输出redis cluster的主从对应关系
需求:给点一批ip列表,一个数组或者一个文件,每行一个ip,模拟输出redis cluster的组从关系,前者是master_ip:master_port -> slave_ip:slave_p ...
- 如何安装selenium框架
半年前因不满自己工作内容,便到处寻求资料,偶遇分享一套全套教程.开始学习python,后接触selenium有关内容. 前期因为配置环境花了些许时间,后来解决了,回想是如此简单 安装步骤 1.下载py ...
- [TJOI2007] 足彩投注
足彩投注 题目概述 题目背景 了解足球彩票的人可能知道,足球彩票中有一种游戏叫做"胜负彩",意为猜比赛的胜负.下面是一些与胜负彩有关的术语 注 :每一组有效组合数据. 投 注:彩民 ...
- 【NLP】暑假课作业3 - 词性标注(简单词频概率统计)
作业任务: 使用98年人民日报语料库进行词性标注训练及测试. 作业输入: 98年人民日报语料库(1998-01-105-带音.txt),用80%的数据作为训练集,20%的数据作为验证集. 运行环境: ...
- node-express处理表单的接口
写一个小接口,用postman测试接口是否可行
- 【JavaScript】JS总结 – 乱
一. 重要:js中的function函数声明.函数表达式 // 函数声明 // Ex: 会在代码执行之前提前加载到作用域中,即js解析器会优先读取,确保在所有代码执行之前声明已经被解析:所以可以在定义 ...
- Spring Boot源码(二):SPI去除web.xml
SPI广泛用于dubbo,spring boot,spring cloud alibaba等 关于SPI,可见SPI-Service Provider Interface 继续上篇文章 上面三句代码的 ...
- 887. 求组合数 III(模板 卢卡斯定理)
a,b都非常大,但是p较小 前边两种方法都会超时的 N^2 和NlongN 可以用卢卡斯定理 P*longN*longP 定义: 代码: import java.util.Scanner ...
- drf 接口文档
coreapi 参考点击 swagger风格接口文档 参考 参考用例 swagger 使用参考