Dhapu and Binary Numbers
All submissions for this problem are available.
Dhapu loves programming. So naturally she loves the language of ones and zeroes. She has created a function bitcount(x) which returns the number of set bits in the binary representation of the number 'x'.
She would love to stress test her program's performance. She feeds it with queries consisting of 2 integers - l and r. The objective of her program is to find the number 'x' (between l and r, inclusive) such that bitcount(x) is maximum possible. And if there exist multiple such numbers, she wants to print the smallest one.
She wants to check if her results are right. Can you make the same program as she did?
The first line contains integer n — the number of queries
Each of the following n lines contain two integers l and r.
For every query, print the answer to the problem.
1 <= n <= 1000
0 <= l <= r <= 10^18
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, 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, CLOJ, FS|
Fetching successful submissions