Last active
April 15, 2016 21:18
-
-
Save berpj/4fbd6afc7ffa7929da57ebdf199b39f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = gets.strip.to_i | |
t.times do | |
count = 0 | |
x = gets.strip.split.map(&:to_i) | |
y = Math.sqrt(x[0]).floor | |
z = Math.sqrt(x[1]).floor | |
count += 1 if y**2 == x[0] | |
y += 1 | |
while (y**2 <= x[1]) do | |
count += 1 | |
y += 1 | |
end | |
puts count | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment