402064: GYM100637 J Superfactorial numeral system

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Superfactorial numeral systemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

On the most perfect of all planets i1c5l various numeral systems are being used during programming contests. In the second division they use a superfactorial numeral system. In this system any positive integer is presented as a linear combination of numbers converse to factorials:

$$$$$$\frac{p}{q} = a_1 + \frac{a_2}{2!} + \frac{a_3}{3!} + \ldots + \frac{a_n}{n!}\,.$$$$$$

Here $$$a_1$$$ is non-negative integer, and integers $$$a_k$$$ for $$$k \ge 2$$$ satisfy $$$0 \le a_k < k$$$. The nonsignificant zeros in the tail of the superfactorial number designation $$$\frac{p}{q}$$$ are rejected. The task is to find out how the rational number $$$\frac{p}{q}$$$ is presented in the superfactorial numeral system.

Input

Single line contains two space-separated integers $$$p$$$ and $$$q$$$ ($$$1 \le p \le 10^6$$$, $$$1 \le q \le 10^6$$$).

Output

Single line should contain a sequence of space-separated integers $$$a_1, a_2, \ldots, a_n$$$, forming a number designation $$$\frac{p}{q}$$$ in the superfactorial numeral system. If several solution exist, output any of them.

ExamplesInput
1 2
Output
0 1 
Input
2 10
Output
0 0 1 0 4 
Input
10 2
Output
5 

加入题单

算法标签: