Java Coding Problem - 3

<b>Problem Statement:</b>
DieHard3 Prob
  Given two jars of capacity a,b (in litres). Need to find
  if any one of the jars can be filled with exactly c litres of water.
  The input will be given in the format a b c.
  The output should be "YES" or "NO"

  Example:
  5 3 4
  YES
  3 6 4
  NO
  13 12 9
  YES

import java.io.BufferedReader;
import java.io.InputStreamReader;

class TestClass {
    public static void main(String args[] ) throws Exception {
       

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
        String s = br.readLine();
        String[] c = s.split(" ");
       
           
                int a  = Integer.parseInt(c[0]);
                int b = Integer.parseInt(c[1]);
                int d = Integer.parseInt(c[2]);
       
                if(d>Math.max(a, b))
                {
                        System.out.println("NO");
                        return;
                }
               
       
         int min = Math.min(a, b);
         int max = Math.max(a,b);
         
         int gcd  = gcd(max,min);
         
         if(gcd==1 || gcd==d)
         {
                 System.out.println("YES");
         }
         else
         {
                 System.out.println("NO");
         }
         
     
    }
   
    public static int gcd(int a, int b) {
        int t;
        while(b != 0){
            t = a;
            a = b;
            b = t%b;
        }
        return a;
    }
}

Interview Questions: 

Search