Created
March 10, 2019 02:58
-
-
Save whatalnk/348439d4698bbf0b2ae1732dcc998b9d to your computer and use it in GitHub Desktop.
AtCoder ABC #121 D - XOR World
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 = 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