Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created December 9, 2014 01:52
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/206c1f5c24cca103a90f to your computer and use it in GitHub Desktop.
Save whatalnk/206c1f5c24cca103a90f to your computer and use it in GitHub Desktop.
ABC#16
m, d = gets.chomp.split(" ").map(&:to_i)
if m % d == 0 then
puts 'YES'
else
puts 'NO'
end
a, b, c = gets.chomp.split(" ").map(&:to_i)
res1 = a + b
res2 = a - b
if res1 == res2 then
if res1 == c then
puts '?'
else
puts '!'
end
elsif res1 == c then
puts '+'
elsif res2 == c then
puts '-'
else
puts '!'
end
n, m = gets.chomp.split(" ").map(&:to_i)
friends = {}
(1..n).each do |k|
friends[k] = []
end
while line = gets
a, b = line.chomp.split(" ").map(&:to_i)
friends[a] << b
friends[b] << a
end
friends.each do |k, v|
res = []
v.each do |f|
res << friends[f]
end
v << k
puts (res.flatten.uniq - v).size
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment