Created
May 28, 2017 18:47
-
-
Save Rishav159/6677e0eeeae12deb62acf743bc2e5de3 to your computer and use it in GitHub Desktop.
Bond
This file contains hidden or 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
t = int(input()) | |
for test in range(t): | |
n = int(input()) | |
i = 0 | |
while(True): | |
if n < 2**i: | |
i = i-1 | |
break | |
else: | |
i += 1 | |
x = abs(2**i - n) | |
y = abs(2**(i+1) - n) | |
ans = min(x,y) | |
print(ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment