Advertisement
Mishakis

Numbers

Dec 3rd, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Numbers {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int caseA = scanner.nextInt();
  7.         int caseB = scanner.nextInt();
  8.         int caseA2B = scanner.nextInt();
  9.         int caseAB2 = scanner.nextInt();
  10.  
  11.         for (int a = -1000; a <= 1000; a++) {
  12.             for (int b = -1000; b <= 1000; b++) {
  13.                 if (a == 0 || b == 0) {
  14.                     continue;
  15.                 }
  16.                 if ((a == caseA || caseA == 0) &&
  17.                         (b == caseB || caseB == 0) &&
  18.                         (a * a * b == caseA2B || caseA2B == 0) &&
  19.                         (a * b * b == caseAB2 || caseAB2 == 0)) {
  20.                     System.out.println(a + " " + b + " " + (a * a * b) + " " + (a * b * b));
  21.                     return;
  22.                 }
  23.             }
  24.         }
  25.  
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement