There is k resistors, resistance of each of that is 1 Ohm. It is required to solder the circuit from them with common resistance r Ohm, where r – a rational number.
Task. What is the least number of resistors which is necessary for solution of this task?
Notes. Certainly it is supposed both consecutive and parallel connection, and their various combinations. In solving it is required to approximate the received value to within four signs after a comma.
Stream. The input stream sets number of resistors k and a demanded resistance of the circuit. The output stream – should specify the minimum number of resistors, or -1 if it is impossible to solder the necessary circuit.