pat 1054
来源:互联网 发布:lte网络拓扑图 编辑:程序博客网 时间:2024/06/03 10:16
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 information for each pixel. In an image, the color with the largest proportional area is called the dominant color. Astrictly dominant color takes more than half of the total area. Now given an image of resolution M by N (for example, 800x600), you are supposed to point out the strictly dominant color.
Input Specification:
Each input file contains one test case. For each case, the first line contains 2 positive numbers: M (<=800) and N (<=600) which are the resolutions of the image. Then N lines follow, each contains M digital colors in the range [0, 224). It is guaranteed that the strictly dominant color exists for each input image. All the numbers in a line are separated by a space.
Output Specification:
For each test case, simply print the dominant color in a line.
Sample Input:5 30 0 255 16777215 2424 24 0 0 2424 0 24 24 24Sample Output:
24
#include <stdio.h>#include <map>using namespace std;map<int, int> mp;int main(){int m, n;int i, j, tmp;while(scanf("%d%d", &m, &n) != EOF){mp.clear();int max = -1, color = -1;for(i = 0; i < m; i++)for(j = 0; j < n; j++){scanf("%d", &tmp);mp[tmp]++;if(mp[tmp] > max){max = mp[tmp];color = tmp;}}printf("%d\n", color);}return 0;}
- pat 1054
- pat 1054
- PAT 1054
- PAT-1054
- pat 1054
- PAT 1054
- PAT [A] 1054
- pat advanced 1054
- PAT(甲级)1054
- 浙大PAT甲级 1054
- PAT-乙级-1054
- PAT乙级1054
- pat-bl-1054
- PAT甲级1054
- PAT 1054求平均值
- PAT basic 1054
- pat
- 【PAT】
- 【GamingAnywhere源码分析之知识补充五】Windows模拟用户session完成存储权限控制
- 用艺术玩转越野
- 设计模式C++实现(7)——外观模式、组合模式
- 找工作笔试面试那些事儿(3)---内存管理那些事
- css细节很重要!
- pat 1054
- grep命令输出带颜色展示
- apache + mysql + php配置
- 设计模式C++实现(8)——代理模式
- 0-1背包问题
- 送给前线码农的话 – 大牛们的经典语录
- 中国已成为捷豹路虎最大市场
- 设计模式C++实现(9)——享元模式
- 设计模式C++实现(10)——桥接模式