Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # My solution to the problem:
- # https://code.google.com/codejam/contest/2418487/dashboard#s=p0
- def solve(r, t)
- n = (-2*r + 1.0 + Math::sqrt((2*r - 1)**2 + 8*t)) / 4.0
- n = n.ceil
- while 2*n*n + n*(2*r - 1) > t
- n -= 1
- end
- return n
- end
- C = gets.to_i
- for c in 1..C
- r, t = gets.chomp.split.map { |x| x.to_i }
- n = solve(r, t)
- puts "Case ##{c}: #{n}"
- end
Advertisement
Add Comment
Please, Sign In to add comment