Superfactorial Numeral System
InterviewTime limit1sMemory limit1024 MB
Convert the fraction p/q into superfactorial digits a_1, a_2, ... where each a_k is below k and is weighted by 1/k!.
- Level
Medium4 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
On the most perfect planet i1c5l, programming contests use various numeral systems. In the second division, contestants use the superfactorial numeral system. In this system, a number is written as a linear combination of reciprocals of factorials.
Here is a non-negative integer, and each integer with satisfies . Nonsignificant zeros at the tail of a superfactorial representation are omitted. Find the representation of the rational number in the superfactorial numeral system.
Input
A single line contains two space-separated integers and (, ).
Output
A single line with the space-separated integers that form the superfactorial representation of . If several solutions exist, print any of them.