Chemistry
Time limit1sMemory limit1024 MB
Given n tubes holding 1 nanoliter each, pour between equal-volume tubes to leave exactly k nanoliters in tube 1, or report -1.
- Level
Medium5 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Statement
Vasya attends his Chemistry classes. During the latest semester, his group has been studying dry liquids. In a lab session on mixing liquids, Vasya received oxygen oxide. This substance has unpredictable consequences after mixing. The liquid is stable only when it is mixed in a one-to-one ratio.
Vasya has test tubes, and each one contains 1 nanoliter of oxygen oxide. Because of the properties of the oxide, Vasya pours liquid from test tube into test tube so that the resulting volume in test tube doubles. To make the experiment succeed, Vasya needs exactly nanoliters of oxide in one of the test tubes. Help him do this.
Input
The only line contains two integers and (, ).
Output
Output the sequence of pours that leaves exactly nanoliters of oxide in the first test tube.
On the first line, output the number of pours (). Then output lines, each with two integers and (), meaning Vasya pours oxide from test tube into test tube .
If no such sequence exists, output -1. If several solutions exist, output any of them. It is guaranteed that if a sequence exists, one exists with at most pours.