UVa 10014 Simple calculations (数学)2014-07-14 csdn博客 synapse710014 - Simple calculationsTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=99&page=show_problem&problem=955
The Problem
There is a sequence of n+2 elements a
0, a
1,…, a
n+1 (n <= 3000; -1000 <= a
i 1000). It is known that
ai = (ai–1 + ai+1)/2 – ci for each i=1, 2, ..., n. You are given a
0, a
n+1, c
1, ... , c
n. Write a program which calculates a
1.
The Input
The first line is the number of test cases, followed by a blank line.For each test case, the first line of an input file contains an integer n. The next two lines consist of numbers a
0 and a
n+1 each having two digits after decimal point, and the next n lines contain numbers c
i (also with two digits after decimal point), one number per line.Each test case will be separated by a single line.
The Output
For each test case, the output file should contain a
1 in the same format as a
0 and a
n+1.Print a blank line between the outputs for two consecutive test cases.
Sample Input
1150.5025.5010.15
Sample Output
27.85
思路: