ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1047. Простые вычисления

help for Simple CAlculations
Послано Sasko Vuckov 15 сен 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
Послано craiovaacm 16 сен 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
Послано craiovaacm 18 сен 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]);
}