Accounting Numeral System
Time limit1sMemory limit1024 MB
Given n and m, find the unique strictly increasing indices x_1 to x_m such that n is the sum of C(x_i, i), printed from x_m down to x_1.
- Level
Medium6 of 10
- Topics
- Combinatorics, Greedy, Binary search
- Solved
- No attempts yet
Problem
The Accounting Numeral System is the top accounting system in the whole world. Its creator, Dr. Ceizenpok, is the leading expert of the respective authority.
In the accounting numeral system with base , a positive integer is written as a sum of parts:
Here are integers with . The numbers are called accounting indexes. Here , and if .
The number is written as . For example, 9 in base 3 is written as (4)(3)(2), because . The number 1 in base 2 is written as (2)(0), because .
Find the representation of the integer in the accounting numeral system with base .
Input
The only line contains two integers and (, ).
Output
Print one line with space-separated integers that form the representation of in the accounting numeral system. is the leftmost number of the representation, and is the rightmost.