杭电 acm 2011(多项式求和)

多项式求和——秦韶九算法 matlab 求多项式pn​xan​xnan−1​xn−1...a1​xa0​的值。宋代数学家秦九韶将多项式改写成Px((...((ax​an−1​xan−2​x...a2​xa1​xa0​可以大量减少计算次数。其递推式为Sk−1​xSk​ak−1knn−1...21​Sn​an;​​。 阅读详情
题目:
Problem Description
多项式的描述如下:
1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + ...
现在请你求出该多项式的前n项的和。

Input
输入数据由2行组成,首先是一个正整数m(m<100),表示测试实例的个数,第二行包含m个正整数,对于每一个整数(不妨设为n,n<1000),求该多项式的前n项的和。

Output
对于每个测试实例n,要求输出多项式前n项的和。每个测试实例的输出占一行,结果保留2位小数。

Sample Input
2
1 2

Sample Output
1.00
0.50

1.打表过程中,不要忘了强制转换,1.0/n,否则得不到真正的解
2.第二就是注意以下格式了

代码如下:
#include<stdio.h> 
int main() 
{ 
    int n,m,i; 
    double a[1000],j;
    a[1]=1; 
    for(i=2;i<1000;i++) 
    { 
        j=1.0/i;
        if(i%2!=1) 
            a[i]=a[i-1]-j; 
        else 
            a[i]=a[i-1]+j;
    }
    scanf("%d",&n); 
    while(n--) 
    { 
        scanf("%d",&m);
        printf("%.2f\n",a[m]);
    } 
    return 0; 
}


多项式相加求和(C语言链表版) 多项式相加求和(C语言链表) 阅读详情

相关推荐

多项式加法_C语言

题目内容: 一个多项式可以表达为x的各次幂与系数乘积的和,比如: 2x6+3x5+12x3+6x+20 现在,你的程序要读入两个多项式,然后输出这两个多项式的和,也就是把对应的幂上的系数相加然后输出。 程序要处理的幂最大为100。输入格式: 总共要输入两个多项式,每个多项式的输入格式如下: 每行输入两个数字,第一个表示幂次,第二个表示该幂次的系数,所有的系数都是整数。第一行一定是最高幂,最后一行一定是0次幂。 注意第一行和最后一行之间不一定按照幂次降低顺序排列;如果某个幂次的系数为0,就不出现在输入数据中了

国家一级致癌物 1300

hdu 2011 多项式求和

多项式求和<br />Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)<br />Total Submission(s): 11765    Accepted Submission(s): 6983<br /><br /><br />Problem Description多项式的描述如下:<br />1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + ...<br />现在请

killsoon的专栏 1446

Elasticsearch连接中断:深入解析Connection reset by peer问题及优化策略

本文深入解析Elasticsearch连接中断问题,特别是Connection reset by peer错误的成因与解决方案。从TCP层的心跳机制到客户端与服务端的配置差异,详细介绍了网络不稳定、防火墙拦截等常见原因,并提供了六种优化策略,包括KeepAlive调整、TCP参数调优和智能重试机制等,帮助提升Elasticsearch连接的稳定性。

weixin_42546392的博客 413

C++ 多项式求和

题目描述 多项式的描述如下: 1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + … 现在请你求出该多项式的前n项的和。 输入描述 每组输入数据是一个正整数n(n<1000)。 输出描述 对于每个测试实例n,要求输出多项式前n项的和。每个测试实例的输出占一行,结果保留2位小数。 输入样例 2 输出样例 0.50 #include <iostream> #include <iomanip> using namespace std; int main(){

꧁༺ʚvv༒catɞ༻꧂的博客 2861

RFID射频识别技术介绍及简单应用

简单介绍RFID技术及其简单应用,后附简单门禁制作方法和代码

来者皆是客。 1万+

网口电路/Bob Smith电路思考及测试

上表中的数据为实际数据,此时可以看出在结果比对中,分别为以上三种时,结果基本上变化很小,且网口一致性指标都是测试通过的,而且如果真的Bob Smith电路是有阻抗变换的作用的,我的以上操作(保留阻容、去掉电阻、去掉电阻电容)完全破环了阻抗平衡,但是实际上对网口一致性指标没有多大的影响,这是我认为该电路不具有阻抗变换的第一个原因。网口变压器的共模电感,就是电流型中的T10、T14、T17、T18,我们知道辐射超标一般都是共模电流导致的,而共模电感就是来消耗差分线路中的共模电流的,而对差模电流基本无影响。

domen_pan的博客 6077

杭电acm2011多项式求和——C语言

多项式求和 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 136376 Accepted Submission(s): 76439 Problem Description 多项式的描述如下: 1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + … 现在请你求出该多项式的前n项的和。 Input 输入数据由2行组成,首先是一个

student_hwj的博客 708

结构力学程序算法理论基础(一)————虚功原理

1.约束 定义约束:限制质点或者质点系运动的条件称为约束,表示这些限制条件的数学方程称为约束方程。 (1)几何约束 限制质点或者质点系在空间的几何位置的条件称为几何约束.如单摆,其中质点M可绕固定点O在平面Oxy内摆动,摆长为l.这时摆杆对质点的限制条件是:质点M必须在以点O为圆心,以l为半径的圆周上运动.其约束方程为: 又质点M在固定的曲面上运动,那么曲面方程就是质点M的约束方程,即 上...

l93919861的博客 4516

杭电ACM2011-- 多项式求和

题目地址 :多项式求和 /* #include int main() { int n,b; double a[110],x; double z; int i,j; int f; for (i=1;i<101;i++) a[i]=(double)1/(double)i; scanf("%d",&n); while(n--) { scanf

小小暮雨 2663

头歌操作系统 课后作业4.3:段页式内存管理 答案 无解析

头歌操作系统 课后作业4.3:段页式内存管理 答案 无解析

kercii的博客 7548

SPD5 集线器协议内容解析

​ 若不同SPD5 Hub后面的本地侧设备同时发送请求,则是22和23、24的混合过程,先通过LID裁决,再通过HID裁决,这里的LID是本地设备的,若LID一致,则看HID,由于SPD5 Hub的本地侧设备HID均为111,因此实际上是比较SPD5 Hub的HID,这个过程在前文提到,SPD5 Hub会转换HID。​ 若MR27[4]=1且MR27[3:0]=1,如果MR51[3:0]=1时,发送IBI,并且MR48[7]置1,将GETSTATUS CCC的待处理中断位[3:0]更新为0001。

weixin_50591344的博客 3865

杭电ACM 2011 多项式求和

多项式求和 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 26557    Accepted Submission(s): 15428 Problem Description 多项式的描述如下: 1 -

neuxxm的专栏 6912

杭电acm2011多项式求和

多项式求和 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 41794    Accepted Submission(s): 24431 Problem Description 多项式的描述如下: 1 - 1/2 + 1

fingersorry的专栏 642

基于YOLOv8的智能肿瘤检测系统:从图像到诊断的深度学习应用——含代码和论文

本文提出了一种基于YOLOv8深度学习的智能肿瘤检测系统,用于医学影像(CT/MRI/X光)的自动分析与诊断。针对传统人工阅片效率低、主观性强的问题,系统采用最新的YOLOv8目标检测算法,通过改进的C2F骨干网络、Anchor-Free检测头和解耦头等创新设计,实现高效精准的肿瘤定位。文章详细阐述了模型架构、数据处理流程、训练优化方法及PyQt5用户界面开发,为临床提供可靠的AI辅助诊断工具。实验结果表明,该系统在速度和准确率上达到良好平衡,有望提升肿瘤早期筛查效率。

FJN110的博客 206

IDEA的使用指南

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

杭电ACM2011--多项式求和

多项式求和 Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 108816Accepted Submission(s): 61288 Problem Description 多项式的描述如下:1 - 1/2 + 1/3...

ahlt90852036的博客 159

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

杭电ACM 2011 多项式求和-C语言

http://acm.hdu.edu.cn/showproblem.php?pid=2011 #include &lt;stdio.h&gt; int main(){ int m,n,i,j,tmp; double num; while(scanf("%d",&amp;m)!=EOF){ for(i=0;i&lt;m;i++){ scanf("%d",&amp;n); n...

1024 775

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")

杭电ACM_2011_多项式求和

#include<iostream> #include<iomanip> using namespace std; int main() { int m; cin>>m; if(m>=100) { cout<<"input error!"<<endl; return -1; } int n[100]; flo...

John_Ai的博客 380

杭电ACM2011:多项式求和

#include <iostream> using namespace std; int main(){ int m; int a[1000]; cin >> m; for (int i = 0; i < m; i++) cin >> a[i]; double s = 0, t; for (int i = 0; i < m; i++){

咸鱼 517

杭电ACM多项式求和--》2011

#include #include using namespace std; int main() { double sum=0; int n,m; scanf("%d",&n); while(n--) { scanf("%d",&m); for(int i=1;i<=m;i++) {

王洋的专栏 1938

杭电ACM 2011: 多项式求和

原题回顾Problem Description 多项式的描述如下: 1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + … 现在请你求出该多项式的前n项的 Input 输入数据由2行组成,首先是一个正整数m(m<100),表示测试实例的个数,第二行包含m个正整数,对于每一个整数(不妨设为n,n<1000),求该多项式的前n项的和。 Output 对于每个测试实

去实验室,奔跑吧 1145

回温一致法+物联网平衡阀:破解供热二网水力失衡实战指南

集中供热系统中,二次网水力失衡是导致近端过热、末端不热的常见症结。传统人工调节响应慢、精度低,难以应对动态热负荷变化。回温一致法以回水温度作为核心反馈信号,反映各支路实际热量消耗,具有物理意义清晰、工程实现成本低的优势。结合物联网远程控制平衡阀,可持续监测回温数据并自动微调阀位,使各支路流量分配趋近热需求比例,从而提升室温达标率、降低热耗。该方法已在智慧供热改造中广泛应用,适用于住宅小区、公建园区等场景。本文从原理、设备选型、通信组网到现场调试流程,系统拆解回温一致法与二网平衡阀的落地实施要点与常见问题排查

weixin_33795093的博客 370

杭电acm 2011多项式求和

#include int main() { int m,n,i,k;     float s,q,j; while(scanf("%d",&m)!=EOF) { for(i=0;i {k=-1;s=0; scanf("%d",&n); { for(j=1;j { k=k*(-1); q=1/j;    s=s+k*q; } printf("%.2f\n",s);

梦玉的专栏 634

杭电ACM 2011 多项式求和 (C++)

原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=2011

知之者不如好之者,好之者不如乐之者 1154
上一篇: 杭电 acm 2010(水仙花数)
下一篇: 杭电 acm 2012(素数判定)
VIProgram
博客等级 码龄11年 96粉丝 82原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值