Bond And Fond
BOND and FOND are two fast friends. But BOND has lots of games on his PC whereas FOND does not have a PC. BOND will allow FOND to play on his PC if he solves this simple question. BOND gives a number N to FOND. FOND has to find the minimum absolute difference between N and any number A which is a power of 2.
The first line contains an integer T, total number of testcases. Then follow T lines, each line contains N as described above.
For every test case print the answer in a new line.
- 1 ≤ T ≤ 10^5
- 1 ≤ N ≤ 10^18
SubtasksSubtask #1 (20 points), Time limit : 1 sec
1 ≤ T ≤ 100000, 1 ≤ N ≤ 10^5
Subtask #2 (80 points), Time limit : 1 sec
1 ≤ T ≤ 100000, 1 ≤ N ≤ 10^18
Input: 3 1 2 3 Output: 0 0 1
In the sample input 1, the closest power of two which is closest to 1 is 1 itself. Hence answer is 0.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, PAS fpc, PAS gpc, RUBY, PHP, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, ERL, TCL, PERL6, TEXT, SCM chicken, FS|
Fetching successful submissions