Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- namespace Example
- {
- struct Spoint
- {
- public int x, y;
- public static Spoint Get(string points)
- {
- string[] s = points.Split();
- Spoint cur = new Spoint();
- cur.x = Int32.Parse(s[0]);
- cur.y = Int32.Parse(s[1]);
- return cur;
- }
- static int sqr(int x)
- {
- return x * x;
- }
- public static double Range(Spoint a, Spoint b)
- {
- return Math.Sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
- }
- public override string ToString()
- {
- return x.ToString() + " " + y.ToString();
- }
- }
- class Program
- {
- static (Spoint, Spoint) Solve(Spoint[] p)
- {
- int first, second;
- first = second = 0;
- double max = 0;
- double sum = 0;
- for (int i = 0; i < p.Length; i++)
- {
- for (int j = 0; j < p.Length; j++)
- {
- if (i == j)
- continue;
- double cur = Spoint.Range(p[i], p[j]);
- sum += cur;
- }
- Console.WriteLine(sum);
- if (sum > max)
- {
- max = sum;
- first = i;
- }
- sum = 0;
- }
- return (p[first], p[second]);
- }
- static void Main()
- {
- string[] inpLine = null;
- using (StreamReader inFile = new StreamReader("C:/Users/Андрей/Desktop/input.txt"))
- {
- inpLine = inFile.ReadToEnd().Split('\n');
- }
- Spoint[] points = new Spoint[inpLine.Length];
- for (int i = 0; i < points.Length; i++)
- {
- points[i] = Spoint.Get(inpLine[i]);
- }
- var max = Solve(points);
- Console.WriteLine(max.Item1);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement