Create a gist now

Instantly share code, notes, and snippets.

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