atcoder#CADDI2018C. Negative Doubling
Negative Doubling
Score : points
Problem Statement
There are positive integers . Takahashi can perform the following operation on these integers any number of times:
- Choose and multiply the value of by .
Notice that he multiplies it by minus two.
He would like to make holds.
Find the minimum number of operations required. If it is impossible, print -1
.
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
4
3 1 4 1
3
One possible solution is:
- Choose and multiply the value of by . are now .
- Choose and multiply the value of by . are now .
- Choose and multiply the value of by . are now .
5
1 2 3 4 5
0
holds before any operation is performed.
8
657312726 129662684 181537270 324043958 468214806 916875077 825989291 319670097
7