Advertisement
roronoa

ébauche intersection cercles

Apr 26th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3. import java.math.*;
  4. class Solution {
  5.  
  6.     public static void main(String args[])
  7.     {
  8.         Scanner in = new Scanner(System.in);
  9.         int n = in.nextInt();
  10.         float x[] = new float[n];
  11.         float y[] = new float[n];
  12.         for (int i = 0; i < n; i++)
  13.         {
  14.             x[i] = in.nextFloat();
  15.             y[i] = in.nextFloat();  
  16.         }
  17.         int first = 0;
  18.         int last = 0;
  19.         int turn = 1;
  20.        
  21.         while(first < 2)
  22.         {
  23.             for(int i = 0; i < n; i++)
  24.             {
  25.                 for(int j = 0; j < n; j++)
  26.                 {
  27.                     if(i != j)
  28.                     {
  29.                         if(crossTwo(x[i],y[i],x[j],y[j],turn))
  30.                             first++;
  31.                     }
  32.                 }
  33.             }
  34.             turn++;
  35.         }
  36.  
  37.         System.out.println(turn);
  38.     }
  39.     public static boolean crossTwo(float x1, float y1, float x2, float y2, int r)
  40.     {
  41.         double distance = Math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
  42.         if(distance < r)
  43.             return true;
  44.         else
  45.             return false;
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement