WC 5.1 Alien Invasion

SOS!

Alien Invasion !!

ISRO has got confirm information about Alien Invasion on Earth. So it has set up a new space mission which is to attack first, where they have to destory 2 galaxies. The galaxies initially have x and y numbers of planets respectively

You are now Mission Commander and ISRO has provided you with a special Destroyer Space craft to destroy all planets in those 2 evil galaxies, But this space craft allows you to only use two guns:
1. One destroys exactly one planet from both galaxies simultaneously.

2.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 its possible to destroy both the galaxies, and if yes, find the minimum number of gun firings required.

All the Best ! Commander.

Testcase 1:
2 9

Explanation

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)
Output: 12

Testcase 2:
13 14

You need to print the sum of the output of the above two testcases.

This challenge is worth 80 points.

You must be logged in to submit a solution

View ranklist for this challenge
About scoring and submission

Contact Us


Kunal Desai : 7715051136

Neelraj Patil : 9930671144



Privacy Policy