ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1047. Simple Calculations

help for Simple CAlculations
Posted by Sasko Vuckov 15 Sep 2001 02:09
which is the TIP of the of the {a0, an+1, c1, ... , cn}
because my formula is correct but I still get Wrong Answer
Re: help for Simple CAlculations
Posted by craiovaacm 16 Sep 2001 01:35
> which is the TIP of the of the {a0, an+1, c1, ... , cn}
> because my formula is correct but I still get Wrong Answer

Maybe your formula is wrong. It happend to me too the first
time. Here is the code which solves the problem. It was
accepted.

for (int k=n;k>=1;k--)
    {
        a[k]=a[0];
        for (i=k;i>=1;i--)
            a[k]-=i*2*c[i];
        a[k]+=k*a[k+1];
        a[k]/=k+1;
    };
Re: help for Simple CAlculations
Posted by craiovaacm 18 Sep 2001 02:45
> which is the TIP of the of the {a0, an+1, c1, ... , cn}
> because my formula is correct but I still get Wrong Answer

Here you are the program I have sent one more time and it
was accepted.

#include<stdio.h>
#include<string.h>
#include<stdlib.h>


void main()
{
//    FILE *f=fopen("input.txt","rt");
#define f stdin
    int n,i;
    float a[3003],c[3003];

    fscanf(f,"%d",&n);
    memset(a,0,sizeof(a));
    memset(c,0,sizeof(c));
    fscanf(f,"%f %f",&a[0],&a[n+1]);
    for (i=1;i<=n;i++)
        fscanf(f,"%f",&c[i]);
    fclose(f);
    for (int k=n;k>=1;k--)
    {
        a[k]=a[0];
        for (i=k;i>=1;i--)
            a[k]-=i*2*c[i];
        a[k]+=k*a[k+1];
        a[k]/=k+1;
    };
    printf("%0.2f",a[1]);
}