Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.math.*;
- class Solution {
- public static void main(String args[])
- {
- Scanner in = new Scanner(System.in);
- int n = in.nextInt();
- float x[] = new float[n];
- float y[] = new float[n];
- for (int i = 0; i < n; i++)
- {
- x[i] = in.nextFloat();
- y[i] = in.nextFloat();
- }
- int first = 0;
- int last = 0;
- int turn = 1;
- while(first < 2)
- {
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j < n; j++)
- {
- if(i != j)
- {
- if(crossTwo(x[i],y[i],x[j],y[j],turn))
- first++;
- }
- }
- }
- turn++;
- }
- System.out.println(turn);
- }
- public static boolean crossTwo(float x1, float y1, float x2, float y2, int r)
- {
- double distance = Math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
- if(distance < r)
- return true;
- else
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement