Marks :10
: 13 | : 1
An E-commerce company is planning to give cash back. For an order with order ID $$$P$$$ of amount $$$Q$$$, it gives cash back equal to the number of operations needed to make P equal to Q. The allowed operations are:
1) $$$P=P+P$$$
2) $$$P=P-P$$$
3) $$$P=P*P$$$
4) $$$P = P/P$$$
If such a transformation is not possible, then output $$$-1$$$.
First line contains number of test cases $$$T$$$, $$$1 \le T \le 10^5$$$
Next $$$T$$$ lines contain two integers $$$P$$$ and $$$Q$$$ , $$$1 \le P,Q \le 10^9$$$
For each test case output the minimum number of operations needed to make $$$P$$$ equal to $$$Q$$$ , if that is not possible output $$$-1$$$
51 22 15 35 1009 9
1 1 -1 2 0
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.