浙江大学PAT_甲级_1054. The Dominant Color (20)

Ubuntu20.04安装Torque-6.1.2单机版(踩坑篇) 说明:PBS排队系统原先是在Centos7安装使用很顺利,但是有客户需求在Ubuntu20.04上使用,着手在Ubuntu20.04安装上安装的时候发现很多报错,并不能顺利安装,网上查找到的教程,有的说是让放弃转slurm,有的是换源安装,但是安装好的版本很低,有许多bug,不是很好用。经过自己慢慢摸索之后,改了部分配置以及源码之后,能够顺利安装,再次记录一下踩坑心得,与大家一起分享学习。如有问题,欢迎大家来撩。............... 阅读详情

题目链接:点击打开链接

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
我的C++程序:

#include<iostream>
#include<map>
using namespace std;
int main()
{
	int m, n, i = 0;
	map<int, int>ma;//map的值统计数字出现次数
	int temp,max_value=0;
	scanf("%d %d", &m, &n);
	for (i = 0;i < m*n;i++)
	{
		scanf("%d", &temp);//输入数字
		ma[temp]++;
	}
	auto it = ma.begin();
	for (;it != ma.end();it++)//遍历map
	{
		if (it->second > max_value)
		{
			temp= it->first;////记录出现次数最多的数字
			max_value = it->second;//寻找最大出现次数
		}
	}
	printf("%d",temp);
	//system("pause");
	return 0;
}


全面认识PFC和LLC 想象一下,你在拉一辆车,如果你的力气都用在推动车子前进的方向上,这样拉车会比较轻松。而如果你的力气用在不正确的方向,比如侧向、斜向,那就需要更大的力气才能推动车子。PFC就是在帮助电流“朝着正确的方向”流动,这样可以用更少的能量做更多的事情,减少无用的功率损耗。PFC负责将电流方向对齐,让电源效率更高,而LLC负责电压的高效转换,两者配合可以在更宽的负载范围内保持高效率。综上所述,PFC LLC电路是一种高效的电源转换电路,通过PFC模块和LLC模块的组合,实现了从交流电到直流电的高效转换。 阅读详情

相关推荐

腾讯ACE反作弊系统:内核驱动与AI行为分析如何守护游戏公平

在游戏安全领域,反作弊技术是保障公平竞技环境的核心防线。其基本原理是通过监控系统关键行为,识别并阻断非法的第三方程序干预。从技术实现看,现代反作弊方案普遍采用分层防御架构,结合用户态模块进行应用层检测,并依赖内核态驱动实现底层深度监控,以此构建纵深防御体系。这种技术的核心价值在于,它能有效对抗从简单内存修改到高级驱动级作弊等多种威胁,维护游戏经济系统和玩家体验的完整性。随着作弊手段的演进,行为分析与AI赋能变得至关重要,系统通过机器学习模型分析进程行为序列的异常模式,即使面对未知特征的外挂变种也能进行有效识

weixin_33978578的博客 823

1054 The Dominant Color(20分)

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

a131529的博客 482

Ubutntu下使用realsense d435i(二):获取某二维像素点的三维坐标

00 准备工作 准备工作包括安装驱动以及pyrealsense2,具体可参考上一篇: Ubutntu下使用realsense d435i(一):准备工作以及安装pyrealsense2 https://blog.csdn.net/gyxx1998/article/details/121461293 01 通过二维像素点获得物体三维坐标 这个在上一篇已经介绍了代码: realsense d435i获取某像素点三维坐标(计算深度和点云两种方法) https://blog.csdn.net/gyxx1998/

gyxx1998的博客 9949

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

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

qq_43528044的博客 155

ANSYS-CFX,计算时报错,内存参数报错,return code 1【终极解决方案】

ANSYS-CFX,计算时报错,内存参数报错,return code 1【终极解决方案】 在CFX计算时经常会遇到内存不足的错误报告,有的算例网格并不多也会出现这样的问题,本文就最近遇到的内存错误问题以及解决方法进行简单的总结,以供大家参考。 1 CFX-Solver Manager内存种类 打开Define Run,面板上的Partitioner、Solver、Interpolator选项中分别都有关于内存的设置选项。当出现内存不足错误时,应该设置哪一个选项的内存参数,要看是哪一部分的内存不足。 2 C

深海民工CFDer 3万+

卡尔曼滤波调参避坑指南:Q/R参数怎么设?实测5种传感器场景

本文针对卡尔曼滤波在工程实践中Q/R参数设置的难题,提供了一套实用的调参避坑指南。通过分析过程噪声方差Q与测量噪声方差R的物理意义与博弈关系,并结合温度传感器、陀螺仪、超声波测距等五种典型传感器场景的实测效果对比,总结出从噪声估算、离线仿真到收敛测试的系统性调参方法论,帮助工程师快速实现稳定有效的滤波效果。

weixin_29174141的博客 830

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

保姆级教程:用Python+OpenCV实现相移法与格雷码三维重建(从生成条纹到点云生成)

本文详细介绍了使用Python和OpenCV实现相移法与格雷码三维重建的全流程,从条纹生成到点云计算。通过结构光技术,结合相移法和格雷码,实现高精度的三维重建,适用于无纹理物体表面的密集对应点生成。教程包含环境搭建、条纹生成、相位计算、三维点云重建及常见问题排查,适合计算机视觉开发者和研究人员。

weixin_33443333的博客 361

【PAT(甲级)】1054 The Dominant Color

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

weixin_55202895的博客 210

SAP系统从ECC升级至S/4 HANA的实现路径及项目过程

从SAP ECC升级到 S/4 HANA,通常是一个复杂的转型过程,涉及到企业资源规划系统的全面现代化

saplakes的博客 2917

vue3 web项目引入高拍仪

高拍仪的引入步骤就两步,安装SDK,然后根据官网的api进行开发。根据自己需要的功能,请求对应的接口。

qq_42480170的博客 4137

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

#include <stdio.h> #include <vector> #include <algorithm> #define MAX 1<<26 using namespace std; int color[MAX] = {0}; bool cmp(int a, int b) { return color[a] > color[b]; } int main(int argc, char

lambsnow的博客 257

OpenHarmony之Histreamer引擎深度解析:pipeline_core架构如何全面取代GStreamer,一统音视频播放与录制

Histreamer是OpenHarmony多媒体框架的核心媒体引擎,采用架构设计。一个轻量级的媒体引擎组件,提供播放、录制等场景的媒体数据流水线处理。1.播放场景分为如下几个节点:数据源读取、解封装、解码、输出;2.录制场景分为如下几个节点:数据源读取、编码、封装、输出。该引擎从OH5.0开始取代了原有的媒体引擎gstreamer(部分文档还保留较老架构的讲解),提供统一的音视频播放、录制、元数据解析等能力。

m0_67505153的博客 338

【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

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

PAT-ADVANCED1054——The Dominant Color

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

清风阁 242

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

PAT甲级1054

题目 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 str

weixin_45040861的博客 166

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

PAT(甲级)1054

map容器的应用, 由于输入的数据较大,不考虑使用数组记录出现次数,采用map<int,int>建立映射,相同值则+1. #include<bits/stdc++.h> #define lowbit(x) ((x)&(-(x))) #define ll long long #define INF 0x3f3f3f3f #define N 100000 #define...

qq_42836930的博客 321

PAT甲级题目1054 The Dominant Color

**题目大意:**给出一系列数字,找出其中出现次数最多的数字。 代码: #include<iostream> #include<map> using namespace std; map<int,int> intnum; int main() { int n,m,i,j,now,maxn=0,k; cin>>m>>n; for(i=0;i<m;i++) { for(j=0;j<n;j++)

weixin_43801993的博客 103

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 than

naexting的博客 191

自动化测试相关

selenium、python和myeclipse的搭建步骤: 1、下载myeclipse安装配置,参照网上的流程 2、下载python安装配置,参考网上的安装步骤 3、配置脚本所用到的环境 4、selenium和python 1、用到的所有软件及名称 总数:8个 exe: AUTOIT_SVN R1054M.exe PIL-1.1.7.win32-py2.7-安装....

ruofei122的博客 302

PAT 1054求平均值(20分)

本题的基本要求非常简单:给定 N 个实数,计算它们的平均值。但复杂的是有些输入数据可能是非法的。一个“合法”的输入是 [−1000,1000] 区间内的实数,并且最多精确到小数点后 2 位。当你计算平均值的时候,不能把那些非法的数据算在内。输入第一行给出正整数 N(≤100)。随后一行给出 N 个实数,数字间以一个空格分隔。对每个非法输入,在一行中输出,其中X是输入。,其中K是合法输入的个数,Y是它们的平均值,精确到小数点后 2 位。如果平均值无法计算,则用Undefined替换Y。如果K为 1,则输出。

北邮22级信通一枚 320

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 t

博客简介 315

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 d

badmartin的技术世界 1033

1054 The Dominant Color

【代码】1054 The Dominant Color。

daybreak_alonely的博客 360

1054. 求平均值 (20)

1054. 求平均值 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 本题的基本要求非常简单:给定N个实数,计算它们的平均值。但复杂的是有些输入数据可能是非法的。一个“合法”的输

Arrion的博客 1044

The Dominant Color (20)

The Dominant Color (20) 时间限制 1000 ms 内存限制 65536 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小) 题目描述 Behind the scenes in the computer’s memory, color is always talked about as a series of 24 bits of inform...

AixsCode 221
上一篇: 浙江大学PAT_甲级_1050. String Subtraction (20)
下一篇: 浙江大学PAT_甲级_1058. A+B in Hogwarts (20)
pythontojava
博客等级 码龄12年 84粉丝 140原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址