P1887 Maximum Product 3

Description

Find $M$ positive integers that sum to $N$ such that their product is as large as possible. Among all optimal solutions, output the lexicographically smallest one.

Input Format

One line containing two positive integers $N, M$.

Output Format

Output $M$ positive integers that sum to $N$ and whose product is as large as possible, separated by spaces. The sequence should be the lexicographically smallest among all optimal solutions.

Explanation/Hint

For 100% of the testdata, $1 \le N \le 10^{9}$, $1 \le M \le 10^{6}$. It is guaranteed that $N \ge M$. Translated by ChatGPT 5