Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created May 7, 2017 05:01
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/bc5e2b499126ef7733775c99a87d83ee to your computer and use it in GitHub Desktop.
Save whatalnk/bc5e2b499126ef7733775c99a87d83ee to your computer and use it in GitHub Desktop.
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