HDU1121——Complete the Sequence

hdu 1121 差分计算 Complete the Sequence 思路:利用差分思想,计算有规律序列 参考博客: http://blog.youkuaiyun.com/wangjie_wang/article/details/9149683 http://rchardx.is-programmer.com/posts/16142.html题外话,:拉格朗日插值法也是希望找出n个数背后的通项公式。 差分的意思就是指,前一个数减去后一个数。 比如题中序列 1 阅读详情

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1121

题目大意:给你一串有规律的数,让你写出后面C个。

别人都说是差分,但我是根据直觉来做这道题的,因为以前学过等差数列和等比数列,和这有差不多的性质,结果真的一样。就这么递推出来了。其实当你看到第三组样例时,也同样能找出答案。

    0 1 2 3 4 5 6 7 8 9 
 ------------------------------- 
 0   1 1 1 1 1 1 1 1 1 2 11 56 
 1   0 0 0 0 0 0 0 0 1 9 45 
 2   0 0 0 0 0 0 0 1 8 36 
 3   0 0 0 0 0 0 1 7 28 
 4   0 0 0 0 0 1 6 21 
 5   0 0 0 0 1 5 15 
 6   0 0 0 1 4 10 
 7   0 0 1 3 6 
 8   0 1 2 3 
 9   1 1 1  

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int T;
    int a[110][110];
    scanf("%d",&T);
    while(T--)
    {
        int i,j,s,c;
        scanf("%d%d",&s,&c);
        for(i=1;i<=s;i++)
            scanf("%d",&a[1][i]);
        for(i=2;i<=s;i++)
            for(j=s-1;j>=1;j--)
                a[i][j]=a[i-1][j+1]-a[i-1][j];
        /*for(i=1;i<=s;i++)
        {
            for(j=1;j<=s-i+1;j++)
                printf("%d ",a[i][j]);
            cout<<endl;
        }*/
        for(i=2;i<=c+1;i++)
            a[s][i]=a[s][1];
        for(i=s-1;i>=1;i--)
        {
            int t=s-i+1+c;
            for(j=s-i+2;j<=t;j++)
                a[i][j]=a[i][j-1]+a[i+1][j-1];
        }
        /*for(i=1;i<=s+c;i++)
        {
            for(j=1;j<=s+c-i+1;j++)
                printf("%d ",a[i][j]);
            cout<<endl;
        }*/
        for(i=s+1;i<=s+c-1;i++)
            printf("%d ",a[1][i]);
        printf("%d\n",a[1][s+c]);
    }
    return 0;
}



【MATLAB代码】基于水声通信(ACOMMS)下的到达时间差(TDOA)定位的AUV自主导航例程,附完整代码 水下AUV导航系统仿真研究 本研究基于到达时间差(TDOA)技术实现了水下自主航行器(AUV)的三维导航仿真系统。系统采用四个声学信标作为定位基准,通过TDOA测量数据迭代求解AUV位置。仿真结果表明: 导航性能:系统能够有效跟踪AUV从起点(30,30,-20)到目标点(70,70,-20)的航行轨迹,定位误差保持在合理范围内。 误差分析:定位误差变化曲线显示系统具有稳定的定位精度,平均误差为0.5米左右。 技术特点:采用两步最小二乘迭代算法求解非线性TDOA方程,提高了定位精度和计算效率。 该仿真系统为 阅读详情

相关推荐

从Stereo-seq原始数据到Seurat对象:华大空间转录组分析流程实战解析

本文详细解析了从Stereo-seq原始数据到Seurat对象的完整分析流程,重点解决华大空间转录组数据处理中的三大痛点:bin_size参数设置、批量处理内存管理及格式转换信息丢失。通过Python的stereopy库和R的SeuratDisk包,实现.gem到.h5ad再到.h5seurat的高效转换,为研究者提供了一套可复用的空间转录组分析解决方案。

weixin_30315723的博客 217

hdu-1121(差分法--数学问题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1121 参考文章:https://blog.youkuaiyun.com/fengzhizi76506/article/details/53729148 思路:有一个n阶序列P(n),从第二项开始每一项减去前一项得到差组成P(n-1)阶序列,直到第0阶,即P(0)。 eg: i=0 1 2 3 4 5 ...

weixin_30485799的博客 220

【电商风控】电商风控标注是什么

本篇文章给大家谈谈。

866

HDU 1121 Complete the Sequence 数学题

题目大意: 就是给出一个长度为n的数列, 是一个多项式

Gatevin的专栏 1235

Marin说PCB之LPDDR5的布线注意事项--01

以上就是本期所有内容了,有些是通用的LPDDR5的设计准则,有的是针对单板的设计规则,严格意义说是没有哪一种规则是完全适用的LPDDR5的 通用规则的,不同的单板可能板厚,板材,层数,SOC以及DDR的型号都是不同的,一般的做法就是严格按照SOC手册上的LPDDR5的要求加上仿真同事给的建议修改优化就好了,我们下期文章不见不散。我们知道想要做好一个LPDDR颗粒,需要考虑的是因素有很多例如,电源完整性,信号完整性,层叠的设计,布局的摆放,布线的合理规划,去耦电容的摆放等等。

weixin_45223454的博客 3161

从PHY芯片看工业网络精准时钟:IEEE 1588v2(PTP)协议实现与选型指南

本文深入解析了工业网络中IEEE 1588v2(PTP)协议的实现与PHY芯片选型要点。通过对比KG7101、RTL8211F等芯片的关键参数,揭示硬件时间戳对纳秒级时钟同步的决定性作用,并提供PTP网络设计中的拓扑布局与配置优化技巧,助力工业自动化场景实现精准时间同步。

weixin_42628688的博客 500

数论+差分 hdu1121 Complete the Sequence

数学真的是神奇啊 第一次见差分这个东西 对于数列a1 , a2 , a3 , a4  a2-a1,a3-a2,a4-a3 为一阶差分(b1,b2,b3) b2-b1,b3-b2 为二阶差分 然后对于题目中的这种多项式 P(n) = aD.n^D+aD-1.n^D-1+...+a1.n+a0  p 的D-1阶差分就绝对可以得到一个常数(这个可以证明) 现在我们在D-1阶差分的结果后面加

meixiuxiudd的博客 642

阿里云大模型 ACP 认证教材内容突变?这些改动藏着通关密码,不看亏大!

【摘要】核心章节大换血,安全合规融入实战场景,大模型微调用数学深度解析,部署章节带来阿里云产品对比实战攻略,甚至整章内容被替换成藏满学习彩蛋的行业趋势指南。这些改动不仅重塑考试重点,更暗藏官方命题风向——安全合规考场景方案,微调原理考几何解析,部署设计考分析框架。无论你是数学小白还是部署新手,这篇攻略都将带你吃透变动逻辑,附赠急救包和考点清单,帮你抓住这些“隐形加分项”,速来解锁通关秘籍!

davidkorhenn的博客 1755

【HDU】 1121 Complete the Sequence

Complete the Sequence题目链接 Complete the Sequence 题目大意    这题题意挺好懂的,就是给你一列数,现在然你找规律找到后面S位是什么。题解    首先这题是用差分求解。     关于这题为什么要差分,我不知道….看了好多东西还是不懂…我这里就直接写解法吧。     我们对前面n个数,求其差分,从1阶差分一直求到n-1阶差分,可以想到如果在第k阶差分全

S_Black的专栏 639

5G无人机安全研究综述

国内多所高校提出混合信任模型,南京航空航天大学于2020年提出了起源信息感知的无人机网络信任模型[26],模型基于报文的完整性对报文创建和操作节点的行为评判并生成观测证据,收集证据进行信任评估,识别网络中的恶意节点并进行路由隔离,实现准确的对等信任评估。同时,5G技术的高速率、高可靠性、低时延等特点,能够为无人机提供实时高清图像回传,保证通信网络的稳定,拓展无人机飞控距离限制,丰富了5G无人机的应用场景。5G和无人机技术的融合,丰富了传统无人机的应用服务场景,然而5G无人机仍存在安全隐患。

weixin_70923796的博客 765

详解FreeRTOS:FreeRTOSConfig.h系统配置文件(拓展篇—1)

FreeRTOS的系统配置文件为FreeRTOSConfig.h,在配置文件中可以完成FreeRTOS的裁剪和配置,这是非常重要的一个文件,本篇博文就来讲解这个文件。

不脱发的程序猿 1545

hdu1121 Complete the Sequence

HDU1121 题意:给你一个整数序列包含S个整数,让你找到这个序列满足的多项式 P(n) = aD.n^D+aD-1.n^D-1+...+a1.n+a0,当这个多项式的阶最小时,输出接下来的满足这个多项式C个整数 差分。计算xi相邻两项差 得序列x2i,计算x2i相邻两项差 得序列x3i,重复以上过程,直到xni的各项值相等。再回算。 #include #inc

Strangedbly 1107

RK3399平台开发系列讲解(内核入门篇)1.1、通过sysfs清楚了解设备的系统状况

文章目录1、不敢高声语,恐惊天上人:sysfs目的2、窥一斑而知全豹:sysfs目录介绍3、千丝万缕:sysfs中要素的关系4、数据观星:sysfs中相关结构体 1、不敢高声语,恐惊天上人:sysfs目的 我们想通过sys下面的目录和文件清楚的了解跑Liunx系统的嵌入式设备的系统状况。 2、窥一斑而知全豹:sysfs目录介绍 sysfs把连接在系统上的设备和总线组织成为一个分级的文件,它们可以由用户空间存取,向用户空间导出内核的数据结构以及它们的属性。sysfs的一个目的就是展示设备驱动模型中各组件.

内核笔记 1万+

HDU 1121 Complete the Sequence

看完题目,我立马就想到了用线性代数里的用矩阵来求解线性的方法,我想的是利用序列的前x个来求出x-1阶的个项系数,然后再用后面为用的数来验证这个多项式的正确性, 写了一晚上,出现了各种扯淡的错误。 最后实在写不出来了,搜了网上的题解,看完之后,才发现其实这题的代码量是很少的。算法是用差分。 思路:对于1 2 4 7 11 16 22 29这个数列,我们对于每一项做其和前一项的差,也就是2-1=

little_胖的专栏 1145

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

hdu 1121 Complete the Sequence(插值差分)

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1121 Complete the Sequence Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 406    Accepted

theArcticOcean 966

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

hdu 1121 Complete the Sequence 差分

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1121 给个解题报告吧http://rchardx.is-programmer.com/posts/16142.html 这题周赛是 没思路 View Code 1 #include <iostream> 2 #include <cstring> 3 #inclu...

weixin_30270889的博客 127

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

杭电ACM HDU 1121 Complete the Sequence

Complete the Sequence Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 185    Accepted Submission(s): 104 Problem Description You prob

gubojun的专栏 1878

HDU 1121 Complete the Sequence 差分

使用差分的方法画一个倒三角,找到规律以后做递推。以前从不晓得差分法,差点就上高斯消元了。 #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;string.h&gt; #include&lt;algorithm&gt; using namespace std; int f[110][110],s,c,t; int main...

weixin_39399748的博客 369

hdu 1121 Complete the Sequence(DP多项式差分)

Complete the Sequence Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 161    Accepted Submission(s): 93 Problem Description You proba

nealgavin的专栏 706

hdu1121 Complete the Sequence

http://acm.hdu.edu.cn/showproblem.php?pid=1121 题目大意:给你一个整数序列包含S个整数,让你找到这个序列满足的多项式 P(n) = aD.n^D+aD-1.n^D-1+...+a1.n+a0,当这个多项式的阶最小时,输出接下来的满足这个多项式C个整数 算法分析:hdu推荐为dp题,没思路,找到解题报告(http://rchardx.is-progr...

weixin_30593443的博客 141

hdu1121Complete the Sequence

一看到它就懵了,后来看了题解,原来这道题目跟我们以前学过的数学斜率知识很像,一阶的斜率为一个数,二阶的斜率为一个一阶数组.....所以用差分就可以解决这个问题 说说我所犯下的错误吧——一个无形的空格号 for(i=n+1;i<=n+m;i++)cout<<f[0][i]<<' ';cout<<endl;结果呢,在每种情况的输出后面多了一个空格 ...

weixin_30586257的博客 116

HDU动态规划——1114.Piggy-Bank,1121.Complete the Sequence,1158.Employment Planning

动态规划的核心思想是通过保存子问题的解来避免重复计算,从而提高效率。通过逐步计算每个位置和取值的最小代价,最终得到整个问题的最优解。数组用于记录达到每个重量时的最小价值。通过不断考虑每种硬币的加入,逐步更新。否则输出达到目标重量时的最小价值。,则表示无法达到目标重量,输出“数组,最终得到达到目标重量。

u014114223的博客 785

HDU1121 Complete the Sequence(差分找规律)

题目大意:给你一串有规律的数,让你写出后面C个。 #include <iostream> using namespace std; const int maxn=100+5; int s,c,T; int f[maxn][maxn]; int main() { cin>>T; while(T--) ...

weixin_30273501的博客 245

HDU 1121差分

#include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <algorithm> #include <map> #include <vector> #include <stack> using namespace std; #define M 105 #

题目实力吊打我,怎么能说我菜 305
上一篇: HDU2062——Subset sequence
下一篇: POJ3259——Wormholes
yphacker
博客等级 码龄12年 199粉丝 540原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值