All submissions for this problem are available.Guardians of the Galaxy were reinstated under Rocket after Thanos killed all the rest. They have set on a new space mission, where they have to destroy $2$ galaxies ruled by Discordiana and Hypnotos (siblings of Thanos).The galaxies initially have $D$ and $H$ number of planets. You are now a guardian and Rocket has ordered you to destroy all the planets in both of the evil galaxies, but he allows you only two guns- - one destroys exactly one planet from both the galaxies simultaneously (can be done only if possible) - the other cuts in half each planet from one galaxy of your choice and in effect doubles the number of planets. You have to find whether it’s possible to destroy both the galaxies, and if yes, the minimum number of gun firings required. ###Input: - First line will contain $T$, number of testcases. Then the testcases follow. - Each testcase contains of a single line of input, two integers $D, H$. ###Output: For each testcase, output a single integer denoting the minimum number of gun firings required. Print $-1$ if not possible. ###Constraints - $1 \leq T \leq 50$ - $0 \leq D, H \leq 10^5$ ###Sample Input: 2 2 9 13 14 ###Sample Output: 12 15 ###EXPLANATION: The following sequence of pair of $(D,H)$ will give:- (2,9)->(1,8)->(2,8)->(4,8)->(8,8)->(7,7)->(6,6)->(5,5)->(4,4)->(3,3)->(2,2)->(1,1)->(0,0)
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, 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, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.