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

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

WHY WA ON TEST #4??I am really stuck in this!!!plz help!
Послано michel mizrahi 11 апр 2005 05:19
I can't understand what's wrong with my code
is my algorithm wrong? or what?
my code:

#include <stdio.h>
#include <math.h>
double x[102],y[102];

double dist(int i, int j){
    int d1=abs(x[i]-x[j]),d2=abs(y[i]-y[j]);
    if(d1==0)
        return (d2);
    else if(d2==0)
      return (d1);
    else
      return sqrt(d1*d1 + d2*d2);
}

int main(){
    int i;
    double n,s=0,r,pi=2*acos(0);
  scanf("%Lf %Lf",&n,&r);
  for(i=0;i<n;i++)
      scanf("%Lf %Lf",&x[i],&y[i]);
    for(i=1;i<n;i++)
        s+=dist(i,i-1);
    s+=dist(0,n-1);
    s+=2*pi*r;
    printf("%.2Lf\n",s);
  return 0;
}

if someone can help me I would appreciate very much
thanks!
Re: WHY WA ON TEST #4??I am really stuck in this!!!plz help!
Послано Sandro 11 апр 2005 08:52
Your algorithm is right. But it seems to me very strange, that d1 and d2 in your code are integers, while x and y are not.

double x[102],y[102];
double dist(int i, int j){
int d1=abs(x[i]-x[j]),d2=abs(y[i]-y[j]);
...}

And double n seems strange to me too.
Re: WHY WA ON TEST #4??I am really stuck in this!!!plz help!
Послано Cybernetics Team 11 апр 2005 15:14
Test #4:
3 1.2
12.24 13.34
0.00 24.75
-33.36 70.12

Solution:
153.41
Re: WHY WA ON TEST #4??I am really stuck in this!!!plz help!
Послано michel mizrahi 12 апр 2005 09:13
thank you both of you guys :D!!!!!! (and sorry for my bad english :$)
I finally got ac, just some stupid and silly mistakes!
Re: WHY WA ON TEST #4??I am really stuck in this!!!plz help!
Послано thamizhkavingan 21 апр 2019 13:25
the answer should be 149.64 isn't it??? where am I wrong?
Re: WHY WA ON TEST #4??I am really stuck in this!!!plz help!
Послано Znol 20 ноя 2019 17:27
.

Edited by author 20.11.2019 17:29