[HackerRank][Python3] Maximizing XOR
2018. 9. 8. 23:50 |
프로그래밍/HackerRank
Problem :
https://www.hackerrank.com/challenges/maximizing-xor/problem
My Solution :
#!/usr/bin/env python3
def maximizing_xor(l, r):
xor = l ^ r
n = 0
while xor:
n += 1
xor >>= 1
return 2**n - 1
l = int(input())
r = int(input())
result = maximizing_xor(l, r)
print(result)
Comment :
bit 연산 문제는 항상 자신이 없다 ㅠㅠ
'프로그래밍 > HackerRank' 카테고리의 다른 글
[HackerRank][Python3] Jesse and Cookies (2) | 2018.09.09 |
---|---|
[HackerRank][Python3] Tower Breakers (0) | 2018.09.09 |
[HackerRank][Python3] Game of Stones (0) | 2018.09.09 |
[HackerRank][Python3] Sum vs XOR (0) | 2018.09.09 |
[HackerRank][Python3] Permuting Two Arrays (0) | 2018.09.08 |
[HackerRank][Python3] Jim and the Orders (0) | 2018.09.08 |
[HackerRank][Python3] Largest Permutation (0) | 2018.09.08 |
[HackerRank][Python3] Priyanka and Toys (0) | 2018.09.08 |
최근에 달린 댓글 최근에 달린 댓글