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

Please help me found error, test4 CRASH C#
Posted by prog_hoz 25 Oct 2011 04:35
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _1020
{

    public class _1020
    {
        public static void Main(string[] args)
        {
            string stroka_vxod = Console.ReadLine();
            string[] strohki = stroka_vxod.Split(' ');
            int n = int.Parse(strohki[0]);
            double r = double.Parse(strohki[1]);
            double dov_nut = 0;
            dov_nut += Math.PI * 2 * r;
            double[,] d = new double[2, n];
            double x1, x2, y1, y2;
            for (int i = 0; i < n; i++)
            {
                string vxid_point = Console.ReadLine();
                string[] pointu = vxid_point.Split(' ');
                d[0, i] = double.Parse(pointu[0]);
                d[1, i] = double.Parse(pointu[1]);
                if (i > 0)
                {
                    x1 = d[0, i];
                    x2 = d[1, i];
                    y1 = d[0, i - 1];
                    y2 = d[1, i - 1];

                    double tum_sum = 0;

                    tum_sum = Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
                    dov_nut += tum_sum;


                }


            }
            double  x0 = d[0, 0];
            double y0 = d[1, 0];
            double xl = d[0, n - 1];
            double yl = d[1, n - 1];
            double last_sum = 0;
            last_sum = Math.Sqrt((xl - x0) * (xl - x0) + (yl - y0) * (yl - y0));
            dov_nut += last_sum;
            double final = double.Parse(dov_nut.ToString("F2"));
            Console.Write(final);

        }

    }

}



Thanks!