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 1020. Rope

Shit , Whats wrong with my code ???
Posted by Li ZhaoFu 23 May 2003 05:22
/*
 * URAL v1 1020
 * ID : ******
 * 2003 - 05 - 22
 */

#include<stdio.h>
#include<math.h>

#define Pi 3.14

typedef struct Nail Nail;
struct Nail
{
  double x;
  double y;
};

double cal(int x,int y)
{
  return sqrt(x*x+y*y);
}

int main()
{
  int N;
  double R,length = 0,curve;
  int i;
  Nail nail[100];

  /* read data */
  scanf("%d %lf",&N,&R);
  for(i = 0;i < N;i++)
    scanf("%lf %lf",&nail[i].x,&nail[i].y);

  curve = 2*Pi*R;
  /* calculate */
  for(i = 0;i < N;i++)
    if(i == N-1)
      length += cal(nail[i].x - nail[0].x,nail[i].y - nail[0].y);
    else
      length += cal(nail[i].x-nail[i+1].x,nail[i].y-nail[i+1].y);

  /*  output */
  printf("%.2f",length+curve);

  return 0;
}
my email is : do_o3@hotmail.com
Posted by Li ZhaoFu 23 May 2003 06:10