Created
March 19, 2017 05:49
-
-
Save whatalnk/f84b99b69571847a440024e9e4c32599 to your computer and use it in GitHub Desktop.
AtCoder ABC #056 [Ruby]
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
a, b = gets.chomp.split(" ") | |
if a == "H" then | |
if b == "H" then | |
ret = "H" | |
else | |
ret = "D" | |
end | |
else | |
if b == "H" then | |
ret = "D" | |
else | |
ret = "H" | |
end | |
end | |
puts ret |
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
w, a, b = gets.chomp.split(" ").map(&:to_i) | |
if b + w < a then | |
ret = a - (b + w) | |
elsif a + w < b then | |
ret = b - (a + w) | |
else | |
ret = 0 | |
end | |
puts ret |
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
x = gets.chomp.to_i | |
sum = 0 | |
i = 1 | |
while true | |
if 2 * x <= (1 + i) * i then | |
puts i | |
exit | |
end | |
sum += i | |
i += 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment