Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created January 8, 2017 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/c249b317fffa25c00b9bea2cf9f9f4ab to your computer and use it in GitHub Desktop.
Save whatalnk/c249b317fffa25c00b9bea2cf9f9f4ab to your computer and use it in GitHub Desktop.
AtCoder ABC #051 [Ruby]
puts gets.chomp.split(",").join(" ")
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
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