Time limit
2s
Memory limit
128 MB
Hongjun has A zeroes and B ones. The goal is to make every number equal to 1.
In one turn, he chooses exactly K numbers and flips their values. A 0 becomes 1, and a 1 becomes 0. On every turn, he may choose any K numbers among the A+B numbers, regardless of their current values or whether they were chosen before.
Find the minimum number of turns needed to reach the goal. If it is impossible, output -1.
The first line contains three integers A, B, and K.
Print the minimum number of required turns on the first line. If it is impossible to make every number equal to 1, print -1.