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【数列】相关推荐

  1. 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]- ...

  2. uva 10014 Simple calculations(数学推导)

    直接按照题意来推导最后的结果就行了. 开始的时候只做到了第一个推导,第二次没有继续下去. 代码: #include<stdio.h>int main() {int T, n, i;doub ...

  3. Competitive Programming 3题解

    题目一览: Competitive Programming 3: The New Lower Bound of Programming Contests(1) Competitive Programm ...

  4. AOAPC I: Beginning Algorithm Contests 题解

    AOAPC I: Beginning Algorithm Contests 题解 AOAPC I: Beginning Algorithm Contests (Rujia Liu) - Virtual ...

  5. TYUT-A专题题解(一)

    TYUT-A专题题解(一) 01A Ad Hoc UVA353 LA5247 Pesky Palindromes[回文] - 海岛Blog - CSDN博客 UVA947 Master Mind He ...

  6. ACM程序设计基础题解

    ACM水题一 HDU1262 寻找素数对[素数] - 海岛Blog - CSDN博客 HDU4548 美素数[水题] - 海岛Blog - CSDN博客 HDU2503 a/b + c/d[水题] - ...

  7. ACM程序设计基础(2)题解

    ACM水题二 CodeForces-1A Theatre Square[水题] - 海岛Blog - CSDN博客 AOJ0009 Prime Number[筛选法+前缀和] - 海岛Blog - C ...

  8. Building credit scorecards using SAS and Python

    By Andre Violante on The SAS Data Science Blog January 18, 2019Topics | Advanced Analytics Risk Mana ...

  9. 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 ...

最新文章

  1. 对于量子计算来说,99%的准确度足够吗?
  2. 虚拟主机,连接mysql及论坛安装
  3. java 类 request_java普通类得到request对象
  4. linux网络编程之socket编程(六)
  5. java指标计算_java – 使用JMH计算指标
  6. 西门子S7系列中间人攻击:防御和流量异常检测(三)
  7. python手册中文版pdf-python中文官方文档 PDF 下载
  8. 自己动手制作USB启动盘
  9. ajax提交form返回数据格式,ajaxSubmit 返回值
  10. 添加页面报警闪烁效果
  11. mysql strlength_mySQL教程 第7章 存储过程和函数
  12. Win8 配置局域网可以访问IIS网站
  13. cPanel主机自定义php.ini文件
  14. c#Form未能加载文件或程序集的解决方法
  15. oracle 分组first,Oracle分析函数:First_Value
  16. H5实时上传位置定位 pc生成轨迹;h5保持后台运行
  17. 一篇运维老司机的大数据平台监控宝典(1)-联通大数据集群平台监控体系进程详解
  18. 一个简单的拼音输入法,实现常用汉字的输入
  19. SCons教程 (2) SConstruct 文件介绍
  20. redis删除单个key和多个key

热门文章

  1. Asp.net Core之TagHelper
  2. 计算机考试图表怎么做,2017年最新计算机考试Excel知识点:创建图表
  3. MySQL 之事务 及 其隔离级别
  4. python如何求列表中的众数_算法(LeetCode)六种方法求数组中的绝对众数
  5. OpenCV精进之路(十三):角点检测
  6. 使用CImage类将RGB图像转化为灰度图像
  7. tensorflow之XORerr1例题
  8. C语言新手写扫雷攻略1
  9. Tosca:键盘输入字符串
  10. java常用设计模式 看了她,改变你的一生~~~