Click Here to go back to the homepage.

Number Fun Solution:


import java.util.Scanner;

public class Kattis {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    StringBuilder sb = new StringBuilder();
    int cases = Integer.parseInt(sc.nextLine());
    for(int i = 0; i < cases; i++) {
      float int1 = sc.nextInt();
      float int2 = sc.nextInt();
      float int3 = sc.nextInt();
      int possibles = 0;
      if(int2+int1==int3){
        possibles++;
      }
      if(int2-int1==int3){
        possibles++;
      }
      if(int2*int1==int3){
        possibles++;
      }
      if(int2/int1==int3){
        possibles++;
      }
      if(int1+int2==int3){
        possibles++;
      }
      if(int1-int2==int3){
        possibles++;
      }
      if(int1*int2==int3){
        possibles++;
      }
      if(int1/int2==int3){
        possibles++;
      }
      sb.append(possibles>0?"Possible\n":"Impossible\n");
    }
    System.out.println(sb);
  }
}