UVA10014 Simple calculations【数列】
There is a sequence of n + 2 elements a0, a1, . . . , an+1 (n ≤ 3000; −1000 ≤ ai ≤ 1000). It is known that
for each i = 1, 2, . . . , n. You are given a0, an+1, c1, . . . , cn. Write a program which calculates a1.
Input
The first line is the number of test cases, followed by a blank line.
For each test case, the first line of the input contains an integer n. The next two lines consist ofnumbers a0 and an+1 each having two digits after decimal point, and the next n lines contain numbersci (also with two digits after decimal point), one number per line.
Each test case will be separated by a single line.
Output
For each test case, the output should contain a1 in the same format as a0 and an+1.
Print a blank line between the outputs for two consecutive test cases.
Sample Input
1
1
50.50
25.50
10.15
Sample Output
27.85
问题链接:UVA10014 Simple calculations
问题简述:(略)
问题分析:
数列计算问题。
先进行数列通项公式的推导,然后再套公式计算,事情就简单了。
程序说明:(略)
题记:数学问题通常是先进行数学推导,再按照数学公式做计算。
参考链接:(略)
AC的C语言程序如下:
/* UVA10014 Simple calculations */#include <bits/stdc++.h>using namespace std;int main()
{int t;scanf("%d", &t);while (t--) {int n;double a, b, sum = 0;scanf("%d", &n);scanf("%lf%lf", &a, &b);for(int i=0; i<n; i++) {double x;scanf("%lf", &x);sum += (n - i) * x;}printf("%.2f\n", (n * a + b - 2 * sum) / (n + 1.0));if(t)putchar('\n');}return 0;
}
UVA10014 Simple calculations【数列】相关推荐
- URAL 1047 Simple Calculations
URAL_1047 根据原式可以得a[n+1]-a[n]=a[n]-a[n-1]+2*c[n]①,设S[n]=c[1]+c[2]+-+c[n],对①式叠加相消可以得到a[n+1]-a[1]=a[n]- ...
- uva 10014 Simple calculations(数学推导)
直接按照题意来推导最后的结果就行了. 开始的时候只做到了第一个推导,第二次没有继续下去. 代码: #include<stdio.h>int main() {int T, n, i;doub ...
- Competitive Programming 3题解
题目一览: Competitive Programming 3: The New Lower Bound of Programming Contests(1) Competitive Programm ...
- AOAPC I: Beginning Algorithm Contests 题解
AOAPC I: Beginning Algorithm Contests 题解 AOAPC I: Beginning Algorithm Contests (Rujia Liu) - Virtual ...
- TYUT-A专题题解(一)
TYUT-A专题题解(一) 01A Ad Hoc UVA353 LA5247 Pesky Palindromes[回文] - 海岛Blog - CSDN博客 UVA947 Master Mind He ...
- ACM程序设计基础题解
ACM水题一 HDU1262 寻找素数对[素数] - 海岛Blog - CSDN博客 HDU4548 美素数[水题] - 海岛Blog - CSDN博客 HDU2503 a/b + c/d[水题] - ...
- ACM程序设计基础(2)题解
ACM水题二 CodeForces-1A Theatre Square[水题] - 海岛Blog - CSDN博客 AOJ0009 Prime Number[筛选法+前缀和] - 海岛Blog - C ...
- Building credit scorecards using SAS and Python
By Andre Violante on The SAS Data Science Blog January 18, 2019Topics | Advanced Analytics Risk Mana ...
- Codeforce 1255 Round #601 (Div. 2) A. Changing Volume (贪心)
Bob watches TV every day. He always sets the volume of his TV to bb. However, today he is angry to f ...
最新文章
- 对于量子计算来说,99%的准确度足够吗?
- 虚拟主机,连接mysql及论坛安装
- java 类 request_java普通类得到request对象
- linux网络编程之socket编程(六)
- java指标计算_java – 使用JMH计算指标
- 西门子S7系列中间人攻击:防御和流量异常检测(三)
- python手册中文版pdf-python中文官方文档 PDF 下载
- 自己动手制作USB启动盘
- ajax提交form返回数据格式,ajaxSubmit 返回值
- 添加页面报警闪烁效果
- mysql strlength_mySQL教程 第7章 存储过程和函数
- Win8 配置局域网可以访问IIS网站
- cPanel主机自定义php.ini文件
- c#Form未能加载文件或程序集的解决方法
- oracle 分组first,Oracle分析函数:First_Value
- H5实时上传位置定位 pc生成轨迹;h5保持后台运行
- 一篇运维老司机的大数据平台监控宝典(1)-联通大数据集群平台监控体系进程详解
- 一个简单的拼音输入法,实现常用汉字的输入
- SCons教程 (2) SConstruct 文件介绍
- redis删除单个key和多个key