Superfactorial numeral system
면접 대비시간 제한1초메모리 제한1024 MB
유리수 p/q를 a1 + a2/2! + a3/3! + ... 형태의 혼합 진법 표현으로 나타내되, k >= 2에 대해 0 <= ak < k를 만족하고 끝의 0은 생략한다.
문제
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:
Here is non-negative integer, and integers for satisfy . The nonsignificant zeros in the tail of the superfactorial number designation are rejected. The task is to find out how the rational number is presented in the superfactorial numeral system.
입력
Single line contains two space-separated integers and (, ).
출력
Single line should contain a sequence of space-separated integers , forming a number designation in the superfactorial numeral system. If several solution exist, output any of them.