Advertisement
Egonau

1.2-3

Jan 7th, 2023
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner(System.in);
  7.         String[] s = sc.nextLine().split(" ");
  8.         double x1 = Double.parseDouble(s[0]);
  9.         double y1 = Double.parseDouble(s[1]);
  10.         double r1 = Math.abs(Double.parseDouble(s[2]));
  11.         s = sc.nextLine().split(" ");
  12.         double x2 = Double.parseDouble(s[0]);
  13.         double y2 = Double.parseDouble(s[1]);
  14.         double r2 = Math.abs(Double.parseDouble(s[2]));
  15.         double l = Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  16.         if (l==0 && r1==r2 && r1>0 && r2>0){
  17.             System.out.println("infinity");
  18.         }
  19.         else{
  20.             if ((Math.abs((r1+r2)-l)<Math.pow(10,-6)) || (Math.abs(Math.abs(r1-r2)-l)<Math.pow(10,-6))){
  21.                 System.out.println(1);
  22.             }
  23.             else{
  24.                 if ((l-r1-r2<Math.pow(10,-6) && r1+l-r2>Math.pow(10,-6) && r2+l-r1>Math.pow(10,-6))){
  25.                     System.out.println(2);
  26.                 }
  27.                 else{
  28.                     System.out.println(0);
  29.                 }
  30.             }
  31.  
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement