Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
AtCoder AGC #014
a, b, c = gets.chomp.split(" ").map(&:to_i)
ret = 0
while true
break if a.odd? || b.odd? || c.odd?
if ret > 30 then
puts -1
exit
end
aa = (b + c) / 2
bb = (a + c) / 2
cc = (a + b) / 2
a, b, c = aa, bb, cc
ret += 1
end
puts ret
n, m = gets.chomp.split(" ").map(&:to_i)
h = Hash.new(0)
m.times do
a, b = gets.chomp.split(" ").map(&:to_i)
h[a] += 1
h[b] += 1
end
if h.values.all?{|x| x.even?} then
puts "YES"
else
puts "NO"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment