Guest User

Untitled

a guest
Oct 4th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.33 KB | None | 0 0
  1. def calc()
  2.     #input
  3.     input = gets.split(' ').map {|s| s.to_i}
  4.     raise "Wrong number of arguments" if input.length != 4
  5.     r, t, vmouse, vcat, = input
  6.     #calculate
  7.     perim = 2 * Math::PI * r
  8.     dist = [(t * vmouse), perim/2].min
  9.     vcat-vmouse <= 0 ? result = -1 : result = dist / (vcat-vmouse)
  10.     #output
  11.     puts sprintf('%.9f', result)
  12. end
Advertisement
Add Comment
Please, Sign In to add comment