Created
May 7, 2017 05:01
-
-
Save whatalnk/bc5e2b499126ef7733775c99a87d83ee to your computer and use it in GitHub Desktop.
AtCoder AGC #014
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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