Advertisement
knyazer

Untitled

Apr 21st, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. Scanner in = new Scanner(System.in);
  7.  
  8. int x1 = in.nextInt();
  9. int y1 = in.nextInt();
  10. int x2 = in.nextInt();
  11. int y2 = in.nextInt();
  12.  
  13. double dst1 = Math.sqrt(x1 * x1 + y1 * y1);
  14. double dst2 = Math.sqrt(x2 * x2 + y2 * y2);
  15.  
  16. if (x1 * x2 < 0 || y1 * y2 < 0) {
  17. System.out.println((int)(Math.floor(dst1) + Math.floor(dst2)));
  18. }
  19. else {
  20. System.out.println((int)(Math.floor(Math.max(dst1, dst2)) - Math.ceil(Math.min(dst1, dst2)) + 1));
  21. }
  22.  
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement