t = 3.times.map{ gets.to_i } p = t.inject(:lcm) q = t.map{|ti| (p / ti) - 1 }.inject(:gcd) puts "#{p}/#{q}"