import scala.math.Integral object Main { def gcd[T](a: T, b: T)(implicit ev: Integral[T]): T = b match { case 0 => a case _ => gcd(b, ev.rem(a, b)) } def lcm[T](a: T, b: T)(implicit ev: Integral[T]): T = ev.times(ev.quot(a, gcd(a, b)), b) def gcd[T](s: Seq[T])(implicit ev: Integral[T]): T = s.reduce(gcd[T]) def lcm[T](s: Seq[T])(implicit ev: Integral[T]): T = s.reduce(lcm[T]) def reduceRational[T](a: T, b: T)(implicit ev: Integral[T]): (T, T) = (ev.quot(a, gcd(a, b)), ev.quot(b, gcd(a, b))) def main(args: Array[String]): Unit = { val Array(a, b, c) = (0 until 3).map(_ => readLong).toArray val ab = reduceRational((a - b).abs, a * b) val bc = reduceRational((b - c).abs, b * c) val l = lcm(ab._2, bc._2) val x = ab._1 * l / ab._2 val y = bc._1 * l / bc._2 val (numerator, denominator) = reduceRational(l, gcd(x, y)) println(numerator.toString + '/' + denominator.toString) } }