X = gets.chomp A, B = X.split('.') if B C = (A + B).to_i puts Rational(C, 10 * B.size) else puts Rational(A.to_i, 1) end