-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISBN_check.cs
More file actions
74 lines (59 loc) · 1.77 KB
/
ISBN_check.cs
File metadata and controls
74 lines (59 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp6
{
class Program
{
static void Main(string[] args)
{
int N = int.Parse(Console.ReadLine());
List<Point> points = new List<Point>();
List<double> mindistanse = new List<double>();
for (int i = 0; i < N; i++)
{
string[] inputs = Console.ReadLine().Split(' ');
points.Add(new Point(int.Parse(inputs[0]),
int.Parse(inputs[1])));
}
Point start = points[0];
Point startfin = start;
points.RemoveAt(0);
while (points.Count > 0)
{
List<double> distanse = new List<double>();
for (int i = 0; i < points.Count; i++)
{
distanse.Add(start.Distanse(points[i]));
}
double min = distanse.Min();
mindistanse.Add(min);
start = points.Find(p => start.Distanse(p) == min);
int ind = points.IndexOf(start);
points.RemoveAt(ind);
}
mindistanse.Add(startfin.Distanse(start));
int m = (int)mindistanse.Sum();
Console.WriteLine(m);
//Console.ReadLine();
}
}
public class Point
{
public int X;
public int Y;
public Point(int x, int y)
{
X = x;
Y = y;
}
public double Distanse(Point p)
{
int dX = p.X - X;
int dY = p.Y - Y;
return Math.Sqrt(dX * dX + dY * dY);
}
}
}