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

Обсуждение задачи 1020. Ниточка

I know the formula, but something is going wrong during the 3 test.
Послано Mihran Muradyan (Fizmat) 6 май 2009 17:33
I know the formula, but something is going wrong during the 3 test.



#include"iostream.h"
#include"math.h"
double a[1000],l=0,x[1000],y[1000];
int n,i,r;
int main()
{
    cin>>n>>r;
    for(i=0;i<n;i++)
    {
        cin>>x[i];    cin>>y[i];
    }
    for(i=0;i<n;i++)
        l=l+sqrt((x[i]-x[i+1])*(x[i]-x[i+1])+(y[i]-y[i+1])*(y[i]-y[i+1]));
    cout<<l+((6.28)*r)<<endl;
    return 0;
}

Edited by author 06.05.2009 19:34
Re: I know the formula, but something is going wrong during the 3 test.
Послано Aram Taranyan (YSU) 6 май 2009 18:56
Can I see your solution,otherwise I can't help you
Re: I know the formula, but something is going wrong during the 3 test.
Послано Gevorg Soghomonyan(YSU) 6 май 2009 20:48
You can't put 6.28
you can put 2*acos(-1) you may use
#include<iostream>
#include<iomanip>
using namespace std;
.
.
.
cout<<fixed<<setprecision(2)<<...;
Re: I know the formula, but something is going wrong during the 3 test.
Послано Aram Taranyan (YSU) 6 май 2009 20:54
Yes,use acos(-1) and include math.h,Gevorg :)



Edited by author 06.05.2009 20:56
Re: I know the formula, but something is going wrong during the 3 test.
Послано Aram Taranyan (YSU) 6 май 2009 21:01
By the way,you have a[1000],but you don't use it ! P.S You can solve this without any array!
Re: I know the formula, but something is going wrong during the 3 test.
Послано Sergey Lazarev (MSU TB) 7 май 2009 02:37
And don't forget to write
x[n] = x[0];
y[n] = y[0];
after reading coordinates.