Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created March 10, 2019 02:58
Show Gist options
  • Save whatalnk/348439d4698bbf0b2ae1732dcc998b9d to your computer and use it in GitHub Desktop.
Save whatalnk/348439d4698bbf0b2ae1732dcc998b9d to your computer and use it in GitHub Desktop.
AtCoder ABC #121 D - XOR World
A, B = gets.chomp.split(" ").map(&:to_i)
def f(x)
if x.even?
a = x / 2
if a.even?
ret = 0 ^ x
else
ret = 1 ^ x
end
else
a = (x + 1) / 2
if a.even?
ret = 0
else
ret = 1
end
end
ret
end
if A == B
puts A
elsif A > 0
puts f(A - 1) ^ f(B)
else
puts f(B)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment