A1 =?Time limit:5000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total Submission (s): 5300 Accepted Submission (s): 3359
Problem description has the following equation: Ai = (Ai-1 + ai+1)/2-ci (i = 1, 2, 3, ...).
If given A0, an+1, and C1, C2, ..... Cn.
Please program calculate A1 =?
Input inputs include multiple test instances.
For each instance, the first is a positive integer n, (n <= 3000); Then there are 2 numbers a0, an+1. The next n rows have a number ci (i = 1, .... n) per line; the input ends with a file terminator.
Output for each test instance, the A1 (Reserved 2 decimal places) is evaluated in one line.
Sample Input
150.0025.0010.00250.0025.0010.0020.00
Sample Output
27.5015.00
To find patterns in the column.
#include <stdio.h> #include <string.h>int main () { //Freopen ("Stdin.txt", "R", stdin); int n, I; Double C, C, a, b; while (scanf ("%d", &n) = = 1) { scanf ("%lf%lf", &a, &b); C = 0.0; for (i = n; i >= 1; i.) { scanf ("%lf", &c); c + = i * C; } C *= 2.0; printf ("%.2lf\n", (B-c + n * a)/(n + 1)); } return 0;}
HPUOJ1294 A1 =?