Java Reduce a fraction#9650

Java Reduce a fraction

1 second
128 megabytes
Very easy

Reduce a fraction to the lowest terms.

Implement a class Fraction that uses a wrapper class MyLong.

class MyLong // Java
{
  private long a; // one private variable
  MyLong(long a) // Constructor
  public String toString() // Print a variable of type MyLong
  public MyLong Abs() // return the absolute value of variable of type MyLong
  public long GetValue() // return the value of private variable of type long
  private static long gcd(long a, long b) // find the GCD of two variables of type long
  public static MyLong gcd(MyLong a, MyLong b) // find the GCD of two variables of type MyLong
  public MyLong Divide(MyLong a) // divide two numbers
};

class Fraction
{
  MyLong numerator, denominator; // numerator and denominator
  Fraction() // Constructor
  Fraction (MyLong numerator, MyLong denominator) // Constructor
  public String toString() // Print a variable of type Fraction
  public Fraction Reduce() // Reduce a Fraction
};

Input

Two integers and (-10^{18} \le a, b \le 10^{18}).

Output

Print the reduced fraction in the form / .

Examples

Example 1

Loading
Loading