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

WA#3
Posted by zantaz 21 Jul 2013 14:24
import java.io.*;
import java.util.*;

public class JavaApplication10 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner s=new Scanner(System.in);
        int N=s.nextInt();
        int R=s.nextInt();
        ArrayList<Double> gvozdi_x= new ArrayList<>();
        ArrayList<Double> gvozdi_y= new ArrayList<>();
      for(int i=0;i<N;i++)
      {
          double x;
            x = s.nextDouble();
            gvozdi_x.add(x);
          double y;
            y = s.nextDouble();
          gvozdi_y.add(y);
      }
      double d;
      double k=0;
      for(int i=0;i<N;i++)
      {
          if((i+1)==N){
          d=Math.sqrt(Math.pow(gvozdi_x.get(0)-gvozdi_x.get(i),2.0)+(Math.pow(gvozdi_y.get(0)-gvozdi_y.get(i),2.0)));
          }
          else{
          d=Math.sqrt(Math.pow(gvozdi_x.get(i+1)-gvozdi_x.get(i),2.0)+(Math.pow(gvozdi_y.get(i+1)-gvozdi_y.get(i),2.0)));
          }
          k=k+d;
      }
      double P=2*3.14*R;
      k=k+P;
      String l;
      l=String.format("%.2f",k);
      System.out.println(l);
    }
}

Edited by author 21.07.2013 14:49