Dragon

Every S-leg have 1 head. Find the quantity of legs N in K-head dragon, if they have A head and B legs together.
Specifications
Input
4 numbers: S, K, A, B. Every numbers is <= 1000.
Output
The quantity of legs of dragon. If input data is contradiction, then output in file –1, if you have some ways of solution – find free from it.
Problem information
Time Limit: 1 secondsMemory Limit: 64 MB
Balls for the passed test: 10
Complexity: 50% 148/297
Example
Example input4 7 35 36 |
Example output2 |
| ← Mouse and corns | Problems | Gardener-painter → |
