HDU2019_数列有序!

C语言:保持数列有序:有n(约定n<=100)个整数,已经按照从小到大顺序排列好,现在另外给一个整数x,请将该数插入到序列中,并使新的序列仍然有序。 已知数列插入数字排序。 #include <stdio.h> int main(void) { int i, j, n, x; int arr[101]; printf("Input:\n"); scanf("%d%d", &n, &x); while (n != 0 || x != 0) { for (i = 0; i < n; i++)//用到了while——为了判定n和x是否为0和for的循环嵌套,最开始这一点并不容易想到 { scanf 阅读详情

数列有序!


Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 79835    Accepted Submission(s): 33599


Problem Description
有n(n<=100)个整数,已经按照从小到大顺序排列好,现在另外给一个整数x,请将该数插入到序列中,并使新的序列仍然有序。
 

Input
输入数据包含多个测试实例,每组数据由两行组成,第一行是n和m,第二行是已经有序的n个数的数列。n和m同时为0标示输入数据的结束,本行不做处理。
 

Output
对于每个测试实例,输出插入新的元素后的数列。
 

Sample Input
  
3 3 1 2 4 0 0
 

Sample Output
  
1 2 3 4
 

Author
lcy
 

Source


#include<stdio.h>
int main()
{
	int n,m,a[110],i;
	while(scanf("%d%d",&n,&m),n!=0&&m!=0)
	{
		for(i=0;i<n;i++)
			scanf("%d",&a[i]);
		for(i=0;i<n;i++)
			if(m>a[i])
				printf("%d ",a[i]);
			else	break;
		printf("%d",m);
		for(;i<n;i++)
			printf(" %d",a[i]);
		printf ("\n");
	}
	return 0;
}

程序设计第十题 数列有序 Problem Description 有n(n<=100)个整数,已经按照从小到大顺序排列好,现在另外给一个整数x,请将该数插入到序列中,并使新的序列仍然有序。 Input 输入数据包含多个测试实例,每组数据由两行组成,第一行是n和m,第二行是已经有序的n个数的数列。n和m同时为0标示输入数据的结束,本行不做处理。 Output 对于每个测试实例,输出插入新的元素后的数列。 第... 阅读详情

相关推荐

【杭电错题】#11数列有序!——思维转换

数列有序! 题目: 数列有序! Problem Description 有n(n<=100)个整数,已经按照从小到大顺序排列好,现在另外给一个整数m,请将该数插入到序列中,并使新的序列仍然有序。 Input 输入数据包含多个测试实例,每组数据由两行组成,第一行是n和m,第二行是已经有序的n个数的数列。n和m同时为0表示输入数据的结束,本行不做处理。 Output 对于每个测试实例,输出插入新的元素后的数列。 Example Input 3 3 1 2 4 0 0 Example Output 1 2

z 938

2019 数列有序!

                                      数列有序!<br />                                       Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)<br />                                       Total Submission(s): 12842    Accepted S

依然spurs 1418

Calibre提参实战:如何用hcell和xcell文件精准屏蔽模块(附避坑指南)

本文详细解析了Calibre提参过程中hcell和xcell文件的应用技巧,帮助工程师精准屏蔽模块以优化寄生参数提取。通过对比hcell与xcell的核心差异、图形界面与命令行操作指南,以及常见问题排查方法,提升芯片后端设计效率。附避坑指南,解决EETOP论坛热议的模块丢失问题。

weixin_26795617的博客 441

c++有n(n<=100)个整数,已经按照从小到大顺序排列好,现在另外给一个整数x,请将该数插入到序列中,并使新的序列仍然有序

输入数据包含多个测试实例,每组数据由两行组成,第一行是n和m,第二行是已经有序的n个数的数列。n和m同时为0标示输入数据的结束,本行不做处理。对于每个测试实例,输出插入新的元素后的数列。

HZYSX的博客 762

GPT大模型在数学建模中的实战应用:从思路启发到代码生成

数学建模是将现实问题抽象为数学问题并求解的核心方法,其关键在于通过合理的假设与简化,构建可计算的数学模型。传统建模依赖MATLAB等工具进行推演试错,而大语言模型的出现革新了这一范式。GPT等模型通过理解自然语言、辅助逻辑推理与代码生成,能有效提升建模效率与质量,在问题解析、模型构建、算法实现等环节提供关键支持。本文聚焦GPT在数学建模中的具体应用,涵盖赛题解读、模型推导、代码生成与结果分析,并结合实战案例,探讨如何将其作为“副驾驶”融入建模全流程,实现人机协同的智能化建模。

weixin_29061465的博客 326

STM32F401RET6寄存器手册阅读标记

对于时钟树配置,可参考STM32CubeMX中的时钟树配置,STM32CubeMX将基础配置图像化,较为简单。RCC_CR寄存器的HSIRDY位为只读位,当读取值为1时,表示HSI振荡器准备就绪,当HSION位被设置时,HSIRDY会自动设置为低电平。//问题标记:USART配置寄存器信息是如何与USART1/2/3建立联系的(为什么不是三个分别配置)查阅寄存器手册可知,需要配置时钟的模块有:USART1,IO port A。(2)TX配置方法(寄存器手册512页)(4)配置寄存器(寄存器手册548页)

m0_72615170的博客 1469

HDU2019 数列有序!

问题链接:HDU2019 数列有序!。入门训练题,用C语言编写程序。 问题简述:参见上述链接。 问题分析:也许对于本题,会考虑用插入排序来做,那就有点绕远了。只要做排序就有可能可能做数据交换,处理时间就长了。 可以考虑输入的n个数据先存放在数组中,再输出。 各种方案中,一边输入数据,一边输出数据,并且在适当位置输出m的做法,应该是优选方案。因为这样做,省去...

weixin_34290352的博客 187

避开EEGLAB预处理三大坑:ICA跑两小时?滤波顺序错?这份情绪ERP实验避坑指南请收好

本文详细解析了EEGLAB在情绪ERP实验中的常见预处理问题,包括滤波顺序错误、ICA耗时过长等,并提供了实用的避坑指南。通过对比实验数据和技术优化方案,帮助研究者高效处理脑电数据,确保情绪图片诱发的ERP成分分析准确性。特别针对情绪实验的特殊性,给出了滤波顺序、ICA加速和参考电极选择的专业建议。

weixin_28683065的博客 375

HDU 2019 数列有序!

数列有序! Problem Description 有n(n<=100)个整数,已经按照从小到大顺序排列好,现在另外给一个整数x,请将该数插入到序列中,并使新的序列仍然有序。 Input 输入数据包含多个测试实例,每组数据由两行组成,第一行是n和m,第二行是已经有序的n个数的数列。n和m同时为0标示输入数据的结束,本行不做处理。 Output 对于每个测试实例,输出插入新的元素后的数列。 S...

蜗小牛的博客 2万+

【DeepSeek开发入门】DeepSeek API 开发初体验

在人工智能蓬勃发展的时代,DeepSeek作为一款功能强大的AI大模型,为开发者提供了丰富的接口和便捷的开发体验。本文将基于DeepSeek的几个关键接口,带你快速入门,开启DeepSeek开发的探索之旅。通过本文,你已经初步了解了DeepSeek开发中几个重要接口的使用方法,包括列出模型、对话补全和查询余额接口,以及开发过程中的常见问题及解决办法。这是你踏入DeepSeek开发领域的第一步。在后续的学习中,你可以深入研究模型的参数调优,探索不同模型在各种场景下的应用,如利用模型实现更复杂的推理对话功能。

寻道AI,探索AI无限可能! 2767

YOLOv11改进策略【Neck】| 替换RT-DETR中的CCFF跨尺度特征融合颈部结构,优化计算瓶颈与冗余问题

RT-DETR中的CCFF模块用于优化多尺度特征融合,解决传统方法的计算瓶颈与冗余问题,提升模型速度与精度,以适应实时检测需求。

Limiiiing的博客 1833

HDU2019 数列有序![入门]

/* HDU2019 数列有序! */ #include &lt;stdio.h&gt; int main(void) { int n, m, val, i; while(scanf("%d%d", &amp;n, &amp;m) != EOF) { if(n == 0 &amp;&amp; m == 0) break; ...

李浅唱的博客 1050

最详细的 SAP ABAP Web Service 创建和消费步骤讲解

本文原版发表于 SAP 官方社区,当时用的英文版写作,标题为:Step by step to create, consume and trace web service in ABAP system https://blogs.sap.com/2014/05/20/step-by-step-to-create-consume-and-trace-web-service-in-abap-system/ 总共阅读量超过 18 万。 How to create web service provider in A

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 3154

HDU_ACM 2019 数列有序!

数列有序! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 39412    Accepted Submission(s): 16911 Problem Description 有n(n   Inp

646

基于Matlab的无迹卡尔曼滤波惯性导航与DVL组合导航

航天航空领域中的惯性导航是一种基于惯性测量单元(Inertial Measurement Unit,IMU)的导航方法,可以提供航向、速度和位置等信息。深度/速度测量器(Doppler Velocity Log,DVL)是一种常用的传感器,可用于测量水下航行器的速度。通过将DVL与无迹卡尔曼滤波相结合,可以实现高精度的组合导航。本文介绍了基于Matlab的无迹卡尔曼滤波(UKF)惯性导航与DVL组合导航的方法。以上是一种简化的示例代码,您可以根据实际应用需求进行相应的修改和优化。

DevSavantX的博客 424

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

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

HDU 2019 数列有序!

数列有序! Problem Description 有n(n&lt;=100)个整数,已经按照从小到大顺序排列好,现在另外给一个整数x,请将该数插入到序列中,并使新的序列仍然有序。 Input 输入数据包含多个测试实例,每组数据由两行组成,第一行是n和m,第二行是已经有序的n个数的数列。n和m同时为0标示输入数据的结束,本行不做处理。 Output 对于每个测试实例,输出插入新的元素后的数列。...

weixin_43821944的博客 274

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

HDU2019 数列有序!【入门】

数列有序!Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 99399Accepted Submission(s): 41560Problem Description有n(n&lt;=100)个整数,已经按照从小到大顺序排列好,现在另...

海岛Blog 6677

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

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

hdu2019 数列有序!

hdu2019 数列有序!                                题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2019 模拟水 题目大意:插入元素 #include #include using namespace std; int main() { int n,m,a[100]; while(cin>

slicer的技术交流栈 729

HDU - 2019 数列有序!

Description 有n(n<=100)个整数,已经按照从小到大顺序排列好,现在另外给一个整数x,请将该数插入到序列中,并使新的序列仍然有序。 Input 输入数据包含多个测试实例,每组数据由两行组成,第一行是n和m,第二行是已经有序的n个数的数列。n和m同时为0标示输入数据的结束,本行不做处理。 Output 对于每个测试实例,输出插入新的元素后的数列。 Sam...

一定要站在自己热爱的生活里闪闪发光 3万+

HDU 2019 数列有序!

数列有序! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 45321    Accepted Submission(s): 19659 Problem Description 有n(n   Inp

淡定的小鱼 662

HDU2019-数列有序!

数列有序!原文链接:数列有序!Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 90815 Accepted Submission(s): 38226Problem Description 有n(n<=100)个整数,已经按照从小到

IT_xiaolaoshu的博客 466
上一篇: HDU2018_母牛的故事
下一篇: HDU2020_绝对值排序
ZayneHuang
博客等级 码龄10年 5粉丝 116原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值