Created
January 8, 2017 05:27
-
-
Save whatalnk/c249b317fffa25c00b9bea2cf9f9f4ab to your computer and use it in GitHub Desktop.
AtCoder ABC #051 [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
puts gets.chomp.split(",").join(" ") |
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
k, s = gets.chomp.split(" ").map(&:to_i) | |
ret = 0 | |
(0..k).each do |z| | |
(0..k).each do |x| | |
y = s - z - x | |
if y >= 0 && y <= k then | |
ret += 1 | |
end | |
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
sx, sy, tx, ty = gets.chomp.split(" ").map(&:to_i) | |
nv = ty - sy | |
nh = tx - sx | |
p1 = "U" * (nv - 1) + "R" * (nh - 1) + "U" + "R" | |
p2 = "D" * (nv - 1) + "L" * (nh - 1) + "D" + "L" | |
p3 = "L" + "U" * (nv + 1) + "R" * (nh + 1) + "D" | |
p4 = "R" + "D" * (nv + 1) + "L" * (nh + 1) + "U" | |
puts p1 + p2 + p3 + p4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment