Problem C: Divide, But Not Quite Conquer! |
Your goal in this problem is to divide a certain integer n by another integer m until n = 1, obtaining a sequence
of numbers. Lets call a[i] each number of this sequence, and let's say it has k numbers (i.e. you must do k-1
succesive divisions to reach n = 1). You can only have this sequence if the following restrictions are met:
The input will consist on an arbitrary number of lines. Each line will consist of two non-negative integers n,m which are both less than 2000000000. You must read until you reach the end of file.
For each pair n,m you must print the correpondent sequence a (as defined above) in a single line, with each adjacent numbers of the sequence separated by a single space. In the case the sequence doesn't exist because it violates some restriction, just print the phrase "Boring!" in a single line (without the quotes).
125 5 30 3 80 2 81 3
125 25 5 1 Boring! Boring! 81 27 9 3 1