t = 3.times.map{ gets.to_i } p = t.inject(:lcm) n_rot = t.map{|ti| p / ti } n_chaise = [(n_rot[0] - n_rot[2] - 1), (n_rot[1] - n_rot[2] - 1)] q = (0 == n_chaise[1]) ? 1 : (n_chaise[0] - n_chaise[1]) puts "#{p}/#{q}"