HPUOJ1294 A1 =?

Source: Internet
Author: User

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 =?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.