1054. The Dominant Color (20)-PAT

FPGA时钟架构解密:从SRCC/MRCC到全局时钟树的实战指南 本文深入解析Xilinx 7系列FPGA时钟架构,从SRCC/MRCC引脚特性到全局时钟树设计,详细介绍了BUFG、BUFMR等关键组件的应用场景和优化策略。通过对比SRCC与MRCC的驱动范围及适用场景,提供低抖动时钟布线技巧和时钟域交叉(CDC)设计方法,帮助工程师构建高性能FPGA时钟系统。 阅读详情

1054. The Dominant Color (20)

时间限制
100 ms
内存限制
32000 kB
代码长度限制
16000 B
判题程序
Standard

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. A strictly 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 3
0 0 255 16777215 24
24 24 0 0 24
24 0 24 24 24
Sample Output:
24
推荐指数:※※
来源:http://pat.zju.edu.cn/contests/pat-a-practise/1054
这道题目想到了方法就很简单,正好,我看过编程之美2.3寻找发帖”水王“,这一题只是壳子不同,输入的时候不相同的互相抵消,多余一半的肯定不会被抵消完的。通俗的来说:有一个椅子,有很多teams都想坐上去,每个team各个队员的战斗力是一样的(不同team队员遇到1:1消失),同样的成员都会在椅子上。现在所有人混在一起,排成一大队一个一个的去抢椅子,如果有一个team的队员大于总队员一半,1:1战斗完后剩下的一定是他的队员。
不然用map也可以。
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int m,n;
	scanf("%d%d",&m,&n);
	int i,j,candidate,ntimes=0;
	for(i=0;i<m;i++){
		for(j=0;j<n;j++)
		{
			int color;
			scanf("%d",&color);
			if(ntimes==0){
				candidate=color;
				ntimes++;
			}
			else
			{
				if(candidate==color)
					ntimes++;
				else
					ntimes--;
			}
		}
	}
	printf("%d\n",candidate);
	return 0;
}


从零到一:Firefly-RK3399上的Ubuntu镜像构建与GPU加速实战 本文详细介绍了在Firefly-RK3399开发板上从零构建深度优化的Ubuntu系统镜像的全过程,包括交叉编译环境配置、内核定制、GPU加速环境部署(Mesa Panfrost驱动、OpenCL/Vulkan支持)以及深度学习推理优化(TFLite + LinuxNN)。通过实战案例展示了如何充分发挥Mali-T860 GPU的硬件潜力,提升边缘AI应用的性能和能效。 阅读详情

相关推荐

WinDbg调试工具安装全攻略:从下载到配置的保姆级教程(Windows 10/11适用)

本文提供了一份详细的WinDbg调试工具安装与配置指南,适用于Windows 10/11用户。文章对比了WinDbg Preview独立版与SDK内置经典版的区别,并手把手指导从Microsoft Store或Windows SDK完成安装。核心部分重点讲解了如何配置符号文件路径与源代码路径,这是让WinDbg发挥强大调试功能的关键步骤,并针对常见安装问题提供了实用的排错方法。

hp777的博客 386

1054 The Dominant Color(20分)

所以应该使用string存储,先用map存,然后存到数组里排个序。其实就是找出一个矩阵中出现次数最多的元素。

a131529的博客 481

英特尔® NUC迷你电脑实现无人值守自动开机配置指南

本文详细介绍了如何配置英特尔® NUC迷你电脑实现无人值守自动开机功能。从BIOS设置到操作系统级配置,涵盖硬件兼容性确认、电源恢复功能设置及常见问题解决,帮助用户轻松实现设备断电后自动恢复运行,适用于家庭服务器、企业终端等多种场景。

weixin_42638178的博客 472

PAT|1054 The Dominant Color(哈希,查找)

题目描述 在计算机内存的幕后,对于每个像素,色彩总是被称为一系列24位信息。在图像中,具有最大比例区域的颜色称为主色。严格占主导地位的颜色占据了总面积的一半以上。现在给定分辨率为N的M图像(例如800×600),您应该指出严格占主导地位的颜色。 解题思路 根据前两个数确定要输入的数据个数 题中说了给出的用例一定包含正确的解,所以一定会有某一个像素点的值出现的次数在一半以上。 使用哈希,每一个像素点作为哈希的键保存,出现的次数作为值。 输入过程中记录最大的出现次数 最后通过遍历解决即可。 代码 #incl

qq_43528044的博客 155

STM32 HAL库驱动BMP388:从寄存器配置到高精度气压温度采集

本文详细介绍了如何使用STM32 HAL库驱动BMP388气压温度传感器,实现高精度数据采集。内容涵盖从硬件连接到STM32CubeMX配置、关键寄存器解析、驱动源码编写,到核心补偿算法与海拔换算的完整流程,并提供了针对不同应用场景的优化配置与调试技巧,帮助开发者快速构建稳定可靠的测量方案。

weixin_29299807的博客 171

神经网络学习笔记-波尔兹曼(Boltzmann)机

Boltzmann机是一种反馈随机神经网络 两种输出状态,单极性0或1。输出状态的取值根据概率统计法则决定,这种概率统计法则类似Boltzmann分布,部分反馈 它在神经元状态变化中引入了统计概率,网络的平衡状态服从Boltzmann分布,网络运行机制基于模拟退火算法。 离散Hopfield神经网络+模拟退火+隐单元=Boltzman机 DHNN全反馈,转移函数:符号函数 BM机网络拓扑...

求易学堂的博客 2614

PAT甲级---1054 The Dominant Color

PAT甲级—1054 The Dominant Color 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. A strictly

weixin_44411458的博客 195

抄表程序员的DLMS/COSEM协议实战:从抓包到解析,手把手教你读懂IEC62056报文

本文深入解析DLMS/COSEM协议在智能电表通信中的应用,从报文捕获到数据解析的全流程实战指南。涵盖HDLC帧解析、应用层连接建立、数据请求/响应解码等核心内容,并提供Wireshark配置、OBIS代码速查表等实用工具,帮助开发者快速掌握IEC62056标准下的电能表通信技术。

weixin_29178069的博客 299

【PAT(甲级)】1054 The Dominant Color

题目给出N行,M列的颜色,要求你输出其中出现次数最多的颜色。又是一道数字与数字对应的题目,我们用map来存储每个数字出现的次数,再通过循环找到出现次数最多的即可。

weixin_55202895的博客 210

【python】import pandas as pd用法

是 Python 里最常用的数据分析库之一。 的意思是:导入 pandas 库,并给它起个别名 。这样用起来更简洁: 下面总结 pandas 的常见用法(配例子)。目录🔹 1. 数据结构(1) Series(一维数据,类似于数组 + 标签)(2) DataFrame(二维数据表,类似于 Excel 表格)🔹 2. 数据读写🔹 3. 数据查看🔹 4. 数据选择与索引🔹 5. 数据清洗🔹 6. 数据运算🔹 7. 数据筛选(布尔索引)🔹 8. 分组与聚合🔹 9. 排序 Pandas 常用方

2401_86285609的博客 1533

Sparse-ICP—(4) 加权稀疏迭代最近点算法(matlab版)

本文介绍了加权稀疏迭代最近点算法的实现。

点云侠的博客 642

PAT-ADVANCED1054——The Dominant Color

我的PAT-ADVANCED代码仓:https://github.com/617076674/PAT-ADVANCED 原题链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805422639136768 题目描述: 题目翻译: 1054 主色彩 在计算机内存的幕后,颜色总是被称为每个像素的一系列24位信...

清风阁 241

华为OD机试双机位C卷-字符串解密(Py/Java/C/C++/Js/Go)

华为OD机试(机考)双机位C卷 【字符串解密】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试 - 字符串解密。

qq_45776114的博客 734

PAT甲级 1054 The Dominant Color (20 分)

PAT甲级 1054 The Dominant Color(20分)题目Input Specification:Output Specification:Sample Input:Sample Output:题解题目大意非正规思路挫挫的代码絮絮叨叨参考博客 题目 Behind the scenes in the computer’s memory, color is always talked about as a series of 24 bits of information for each pixe

weixin_44585441的博客 277

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

[PAT-Advanced] A1054. The Dominant Color (20)

【代码】[PAT-Advanced] A1054. The Dominant Color (20)

Duke 441

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

[PAT] 1054 The Dominant Color (20 分)Java

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 ...

Simma1101的博客 259

PAT甲级真题-1054 The Dominant Color (20分)

1054 The Dominant Color (20分) 题目链接 1.题意分析:给一个n*m的二维数组,统计出现次数最多的数字。 2.思路分析:用map计数,操作简单。注意:如果使用普通数组计数,则由于数据过大,导致内存超限。 3.代码时间: #include <iostream> #include <string> #include <map> #incl...

qq_43060884的博客 235

pat 1054 The Dominant Color(20 分)

1054The 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...

dggnqzt6462的博客 179

PAT甲级 1054 The Dominant Color (20分)

1054 The Dominant Color (20分) 题目链接:PAT A 1054 题目大意:简单说就是题目中会给出m*n个数,要找出这些数中出现频率最多的一个并输出。 思路分析:直接使用STL中的map统计每个数出现的频率,同时用max记录出现频率最大值。最后遍历map,当某个值与max相等时,输出键即可~ AC代码: #include<iostream> #include...

weixin_43684054的博客 191

PAT A 甲级 1054 The Dominant Color (20分)

1054 The Dominant Color (20分) 吐槽 说实话,我确信我的这个算法不能真正完美解决这个问题。我能简单地想到一个会导致它失效的极端数据。但是题目通过了。果然没有过分到使用那种情况(点头)。 (但是我还是回头去搞出了这道题的完美算法hhhhh) 以及果然cin改scanf是保留项目。 思路 看到题目的那一刻就明白肯定是个用时极限的题目。即使我认定自己的方法已经大幅缩减了题干用...

虚境的博客 190

PAT甲级1054 The Dominant Color (20 分)【STL】

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 p...

Imagirl1的博客 306

pat 1054. The Dominant Color (20)

1054. The Dominant Color (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Behind the scenes in the computer's mem

Yesterday You Said Tomorrow. 369

PAT A1054 The Dominant Color (20 分)

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 p...

小魚兒 217

PAT甲级-1054 The Dominant Color (20分)

点击链接PAT甲级-AC全解汇总 题目: 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...

卷子的博客 301

【PAT甲级A1054】The Dominant Color (20分)(c++)

1054 The Dominant Color (20分) 作者:CHEN, Yue 单位:浙江大学 代码长度限制:16 KB 时间限制:400 ms 内存限制:64 MB 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 pr

小庄同学的博客 258

PAT 甲级 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. A strictly dominant color takes more

qq_45478482的博客 256

PAT 甲级 1054 The Dominant Color (20分)

题目 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. A strict

qq_41001689的博客 225
上一篇: 1055. The World's Richest (25)-PAT
下一篇: 1053. Path of Equal Weight (30)-PAT
zoushidexing
博客等级 码龄18年 70粉丝 171原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值