CCF 201903-1 小中大

CCF 201903-1 小中大 (C++) 201903-1 小中大 试题编号: 201903-1 试题名称: 小中大 时间限制: 1.0s 内存限制: 512.0MB 问题描述: 解题过程 按题意解题即可。 由于输入的均是整数,故中位数的结果最多也就一位小数,不用考虑舍入。 AC代码 #include<iostream> #include<algorithm> using namespace std; int main() { int n; cin>>n; int num[n]; for(int i= 阅读详情

#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	cin>>n;
	int m1,m2;
	double mid=0;
	int temp;
	bool flag=(n%2==0);
	//int count=0;
	/* 
	int midk;
	if(n%2==0) midk=n/2-1;  //中间两个中的第一个 
	else midk=(n+1)/2-1;
	*/
	for(int i=0;i<n;i++)
	{
		cin>>temp;
		if(i==0) m1=temp;
		if(i==n-1) m2=temp;
		if((i==(n-1)/2||i==(n-1)/2+1)&&flag)
		{
			mid+=temp*1.0/2;  //转换为double型 
		}
		if(i==(n-1)/2&&!flag)
		{
			mid=temp;
		}
	} 
	if(m1<m2) swap(m1,m2);
	
	if(mid-(int)mid==0)
	{
		cout<<m1<<" "<<(int)mid<<" "<<m2;
	} 
	else
	{
		//cout<<m1<<" ";
		printf("%d %.1f %d",m1,mid,m2);
		//cout<<m2; 
	}
	
	

	//cout<<m1<<" "<<mid<<" "<<m2;
	return 0;
}

 

ccf专题之201903-1小中大 ccf专题之201903-1小中大 首先附上题面 读题后解题思路 设立A[100001] 设一个n,记录输入多少个数。 最大最小值: max(A[1],A[n])为最大值, min(A[1],A[n])为最小值 中位数: 判断n为偶数还是奇数 若为奇数,则中位数为A[n/2+1] 若为偶数,则中位数为(A[n/2]+A[n/2+1])/2; 此时还要判断(A[n/2]+A[n/2+1])%2是否... 阅读详情

相关推荐

CCF [201903-1] 小中大(C++)

试题编号: 201903-1 试题名称: 小中大 时间限制: 1.0s 内存限制: 512.0MB 问题描述: 解题思路:   略。 答案程序: #include <iostream> using namespace std; const int N = 1e5; int a[N]; int main() { int n; scanf("%d", &n)...

Silly2521的博客 451

CCF计算机软件能力认证真题201903-1(满分) 求最大值中位数最小值

分析 1、因为输入数据是有序的,所以最大值和最小值在所给数据的两端,可直接取出,然后比较,得出最大值和最小值。 2、中位数是按顺序排列的一组数据中居于中间位置的数。假设数据个数为n,数据保存在数组arr[]中,当n为奇数时,中位数为arr[n/2],在c++中,整数除整数,所得的结果是用去尾法处理后的整数,所以索引是n/2,例如当n=3时,n/2=1;当n为偶数时,中位数为居于中间两个数的平均值,即 (arr[n/2-1] + arr[n/2])/2,这时中位数可能是小数或整数,所以应用一个浮点对象来保存.

V_Vi3w 692

CCF计算机软件能力认证试题练习:201903-1 小中大

小中大 来源:CCF 标签: 参考资料: 相似题目: 背景 在数据分析中,最小值最大值以及中位数是常用的统计信息。 题目 老师给了你 n 个整数组成的测量数据,保证有序(可能为升序或降序),可能存在重复的数据。请统计出这组测量数据中的最大值、中位数以及最小值,并按照从大到小的顺序输出这三个数。 输入 从标准输入读入数据。 第一行输入一个整数 n,在第二行中存在 n 个有序的整数,表示...

WINGREZ‘S BLOG 1万+

CCF201903-1 小中大

/*** 这题挺坑的。 首先四舍五入基本上不用考虑,直接%.1f就行了。 其次计算flout时,注意强制转换int为flout再计算。 如 flout mid = (a + b)/2;这mid算出来永远是整数 应写为flout mid = (a + b)/2.0 **/ #include <iostream> #include <stdio.h> //#define debug using namespace std; int main(){ int n,i,a =

weixin_43963453的博客 219

STM32N6570-DK ISP调试

将下载线接入STLINK V3EC接口,将BOOT1拨码拨至右边,即将其置为H,上电或已经上电的按复位,打开STM32CubeProgrammer,设置start address:0x70000000。板子消耗电流较大,即使缩短数据线接了USB供电依然不能正常点亮显示屏,最终通过板上CN2端子加了外部5V供电,仍然需要560mA的外部电流。3.烧录bin文件:STM32N6_ISP_IQTune_App_revC01-v1.1.0-trusted.bin。

liu的博客 1066

线性代数——(期末突击)行列式(上)-行列式计算、行列式的性质

简单解释一下:4213原本的顺序应为1234,对于‘4’而言,‘2’、‘1’、‘3’都应该排在它的前面,所以此处记逆序数为3;对于‘2’而言,‘1’应该排在它的前面,而‘3’排在它之后 是合理的,所以此处只有一个逆序数;最后看‘1’,其后面的‘3’排在后面显然也是合理的,故而4213的逆序数为4.一般我们使用这个性质来计算四阶行列式,也就是将其变换成三角行列式,再计算对角线的值;以主对角线为分界线的就为正三角,反之则为反三角行列式。若行列式某一行(列)为0,则该行列式=0.将和的那一行分开,其余行。

li13437542099的博客 1万+

CCF201903-1 小中大(100分)【序列处理】

问题链接:CCF201903-1 小中大 问题分析: 原先的数据是有序的,所以就不用排序了,可以直接算出中值。最大值和最小值在数据的两端,用两端的数据,至多做个交换就可以得到。还需要考虑中值带小数点的时候,保留1位小数...

海岛Blog 2万+

Diffusion Model原理详解

Diffusion Model(扩散模型 )对标的是生成对抗网络(GAN),本文将用通俗的语言和公式为大家介绍Diffusion Model,并且结合公式为大家梳理Diffusion Model的代码。

weixin_42620109的博客 6102

ccf csp 201903-1 小中大

#include<iostream> #include<iomanip> using namespace std; int main(){ int n; cin >> n; int num[n]; for(int i = 0; i < n; i++) cin >> num[i]; if(num[n -...

lalala_HFUT的博客 2534

全志T113s3主线linux开发(0)--基础准备

嵌入式Linux设备的启动大概是三步:1)启动芯片+内存:常见的是Uboot,不过全志的Uboot主线对SPI NAND 不太友好,用TF卡就方便。对于T113S芯片,推荐使用Awboot,简陋但快速。开发阶段用这个就方便好多,对SPINAND支持也方便。2)启动linux内核:主线内核以下通篇都用6.13以上的内核。对比tina5.0还在用5.4 ,主要是性能、安全上有变化。6.0以上内核在devicetree的编写具体格式上有了变化,网上大量tina5.0和5.4内核的编写方式不适用。

2301_79234138的博客 2248

阿里平头哥与华为芯片的比较

阿里平头哥与华为芯片代表了中国AI芯片领域的两种典型发展路径:平头哥通过兼容CUDA生态快速切入市场,以较低成本提供接近国际水平的AI算力;华为则坚持全栈自研路线,构建从芯片到框架的完整技术体系,更注重供应链安全和自主可控。从短期来看,平头哥PPU在单卡性能参数上全面超越昇腾910B,接近英伟达H20水平,且成本优势明显,有望在云服务和互联网应用领域取得更大市场份额。而华为昇腾则凭借全栈自研和端边云协同优势,在政企市场和科研领域更具竞争力。

shao.bing的专栏 4032

CCF-201903-1-小中大

CCF-201903-1-小中大 问题描述 试题编号: 201903-1 试题名称: 小中大 时间限制: 1.0s 内存限制: 512.0MB 程序代码: #include<iostream> #include<algorithm> using namespace std; const int N = 1e5 + 10; float q[N]; int main() { int n; cin>>n; for.

suxiaorui的博客 447

四参数与七参数坐标转换含义及区别

一.前言 不同坐标系,其椭球体的长半径,短半径和扁率是不同的。比如我们常用的四种坐标系北京54、西安80、WGS84、CGCS2000所对应的椭球体,它们的椭球体参数就各不相同。而不同空间直角坐标系之间的转换一般通过七参数或者四参数来实现坐标转换。 二.四参数转换 两个不同的二维平面直角坐标系之间转换通常使用四参数模型,四参数适合小范围测区的空间坐标转换,相对于七参数转换的优势在于只需要2个公共已知点就能进行转换,操作简单。 在该模型中有四个未知参数,即: (1)两个坐标平...

尘海折柳的博客 1万+

笔记:CCF201903-1 小中大(含100分答案)

#include /* run this program using the console pauser or add your own getch, system(“pause”) or input loop / //CCF201903-1 小中大 int main(int argc, char* argv) { int n; scanf("%d\n",&n); int a[n], ...

追梦鸟 2701

电磁仿真新手必看:如何用CST Studio Suite 2023完成第一个PCB辐射仿真?

本文详细解析了如何使用CST Studio Suite 2023进行PCB辐射仿真,适合电磁仿真新手快速上手。从工程准备、求解器配置到端口设置和后处理技巧,全面覆盖三维全波电磁场仿真软件的核心操作步骤,帮助工程师精准预测和解决PCB电磁辐射问题。

y7z8a9的博客 734

博通PEX89000 PCIe 5.0交换芯片:如何为AI集群构建高效GPU互联架构

本文深入解析了博通PEX89000 PCIe 5.0交换芯片如何为AI集群构建高效的GPU互联架构。该芯片通过提供高带宽、低延迟的PCIe 5.0交换能力,打破传统GPU通信的带宽瓶颈,并支持多主机共享、资源池化及软件定义拓扑,从而显著提升大规模AI训练与推理任务的效率与资源利用率。

weixin_29214559的博客 413

CCF认证201903-1小中大

CCF认证201903-1小中大题目描述算法设计+题目分析注意点+记录点代码(100分)感谢链接 题目描述 201903-1小中大 算法设计+题目分析 吐槽一下 题目不是很难,但是用VC6.0会出现一些bug(推测就是这个ide的问题),问题如下 槽点如图,都是按照整型输出-1,竟然会出现两个不同的值,真的困惑了我半天。。。 算法设计+题目分析 1、维护一个num[100010]的数组; 2、按照...

weixin_38562500的博客 616

深度学习工具包 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")

CCF-CSP 201903-1:小中大(100分)“附踩坑之后痛的领悟”

请认真读题认真读题认真读题 重要的事情说三遍 不然容易心态爆炸哦 问题分析: 第一行先读取一个整数N,然后第二行读取N个整数(默认已经有序,所以不排序) 分别取最大值,最小值和中位数然后输出。 #include<iostream> using namespace std; int a[100005]; class Qu20190301{ private: int N; ...

Love_Star_的博客 843

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

CSP-CCF 201903-1 小中大

一方面,是因为我一开始的思路就出错了,不应该设置中间数mid,因为它可能是整数或小数,设置成int类型或者double类型都不合适、都会出错,可能是类型转换上的错误,总之会导致结果迟迟运行不出来,最后尝试了很久,还是决定放弃、不设置mid、直接输出即可。②输出的数是偶数个,但可以整除((a[n / 2] + a[n / 2 - 1]) % 2 == 0),则中间数是(a[n / 2] + a[n / 2 - 1]) / 2。①输入的数是奇数个(n % 2 == 1),则中间数是a[n/2]

2301_79705447的博客 559

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

CCF 201903-1 小中大 CCF 201903-2 二十四点

CCF 201903-1 小中大 思路 题意比较明确:给定一组有序的数据,求最大最小中位数并按照从大到小的顺序输出 若总数为奇数,则中位数为中间的数,若为偶数,则为中间两个数的平均数。 代码实现 #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 100010; int n; int q[N]; int main() {

weixin_39096053的博客 668

CCF CSP201903-1 小中大

CCF CSP201903-1 小中大 试题编号: 201903-1 试题名称: 小中大 时间限制: 1.0s 内存限制: 512.0MB 非常简单的题目没有什么好说的,需要注意的点就是在输出中位数之前需要判断中位数是不是整数 ,还有就是储存输入数据的数组要建大一点,一开始没注意到题目需求只建了100的数组然后只得了30分。。。这个在考试中也是需要注意的问题,毕竟考试提交不会显示分数,因为这种失...

qq_44379808的博客 581

CCF201903-1小中大

中位数:将数据排序后,位置在最中间的数值。当样本数为奇数时,中位数=第(N+1)/2个数据 ; 当样本数为偶数时,中位数为第N/2个数据与第N/2+1个数据的算术平均值 。(注意:不需要剔除重复的数据之后再计算中位数) 试题编号 201903-1 试题名称 小中大 时间限制 1.0s 内存限制 512.0MB 问题描述 代码: int main() { int n, min, max; float mid;//中位数 float a[10005]; c

weixin_42650040的博客 239
上一篇: CCF 201812-1 小明上学
下一篇: CCF 201909-1 小明种苹果
Estrellas_
博客等级 码龄9年 273粉丝 233原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值