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

Общий форум

Why WA on problem 1020?!!! What's wrong? Help, please...
Послано Osama Ben Laden 8 фев 2002 16:12
#include <iostream.h>
#include <math.h>

int n;
long double r;
long double x[202];
long double y[202];
long double sum=0.0;

const long double pi = 3.141592654;
long double lex(int i, int j)
{
 return sqrtl((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
}
int main()
{
 cin>>n>>r; int i;
 for(i=0; i<n; i++) cin>>(x[i])>>(y[i]);
 for(i=0; i<n-1; i++) sum += lex(i,i+1);
 sum += lex(n-1,0);
 sum += 2*pi*r;
 cout.precision(2); cout.setf(ios::showpoint);
 cout<<(floor(sum*100)/100)<<'\n';
 return 0;
}
Re: Why WA on problem 1020?!!! What's wrong? Help, please...
Послано Aidar 9 фев 2002 06:00
> #include <iostream.h>
> #include <math.h>
>
> int n;
> long double r;
> long double x[202];
> long double y[202];
> long double sum=0.0;
>
> const long double pi = 3.141592654;
> long double lex(int i, int j)
> {
>  return sqrtl((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
> }
> int main()
> {
>  cin>>n>>r; int i;
>  for(i=0; i<n; i++) cin>>(x[i])>>(y[i]);
>  for(i=0; i<n-1; i++) sum += lex(i,i+1);
>  sum += lex(n-1,0);
>  sum += 2*pi*r;
>  cout.precision(2); cout.setf(ios::showpoint);
>  cout<<(floor(sum*100)/100)<<'\n';
>  return 0;
> }
>
Write In Pascal, please!
Accepted Source in Pascacal:
var
  r, P : extended;
  a : array [1..101] of record
    x, y : extended;
  end;
  n, i : byte;


begin
  ReadLn (n, r);
  for i := 1 to n do with a [i] do ReadLn (x, y);
  with a [n + 1] do begin
    x := a [1].x;
    y := a [1].y;
  end;
  P := 2 * pi * r;
  for i := 1 to n do
    P := P +
      sqrt (sqr (a [i + 1].x - a [i].x) + sqr (a [i + 1].y - a
[i].y));
  WriteLn (P:0:2);
end.