Reduce to 1 CodeChef Solution | CodeChef Problem Solution 2022
Arun has an integer . His friend Sucksum likes the number , so Arun wants to reduce to .
To do so, he can perform the following move several times (possibly, zero):
- Pick two integers and such that is even and is a divisor of . Then, replace by
Note that at each step, only needs to be a divisor of the current value of , and not necessarily a divisor of the integer Arun initially started with.
Find the minimum number of moves Arun needs to reduce to . If it is not possible to reduce to using the given operation, print instead.
Input Format
- The first line of input will contain an integer , denoting the number of test cases. The description of test cases follows.
- Each test case consists of a single line of input containing one integer .
Output Format
For each test case, output on a new line the answer — the minimum number of moves needed to reduce to , or if it is not possible to do so.
Constraints
Sample Input 1
2
25
24
Sample Output 1
1
-1
Explanation
Chef and Chapters CodeChef Solution | CodeChef Problem Solution 2022
Presents for Cheffina CodeChef Solution | CodeChef Problem Solution 2022
Chef and Bird farm CodeChef Solution | CodeChef Problem Solution 2022
Valentine Vex CodeChef Solution | CodeChef Problem Solution 2022
Buying Sweets CodeChef Solution | CodeChef Problem Solution 2022
Reduce to 1 CodeChef Solution | CodeChef Problem Solution 2022
Three Arrays CodeChef Solution | CodeChef Problem Solution 2022
Test case : Choose and . is even, and is a divisor of so this is a valid choice of and . Dividing by leaves us with and we are done.
Join Now for Solution:-
Test case : It can be shown that no matter which moves are made, cannot be reduced to .
No comments:
Post a Comment