|
|
вернуться в форумCorrect code in JAVA ( 0.093 s ) import java.util.Scanner; public class _1020 { public static void main( String[] args ) { Scanner in = new Scanner( System.in ); int N = in.nextInt(); double R = in.nextDouble(); double[][] p = new double[N][2]; double PI = Math.PI; double L = 2*PI*R; for( int i=0 ; i<N ; i++ ) { p[i][0] = in.nextDouble(); p[i][1] = in.nextDouble(); if( i>0 ) L += Math.sqrt( (p[i][1]-p[i-1][1])*(p[i][1]-p[i-1][1]) + (p[i][0]-p[i-1][0])*(p[i][0]-p[i-1][0]) ); } L += Math.sqrt( (p[0][1]-p[N-1][1])*(p[0][1]-p[N-1][1]) + (p[0][0]-p[N-1][0])*(p[0][0]-p[N-1][0]) ); System.out.println( String.format("%.2f", L) ); } } |
|
|