#B3855. Fusu Iteration Process

    ID: 11512 Type: Default 1000ms 256MiB

Fusu Iteration Process

Fusu Iteration Process

Given an initial variable \(x_0\) and a positive integer \(a\) (with \(a \ge 2\)), perform the Fusu iteration defined as:

\[ x_i = \left\lfloor \frac{x_{i-1} + a}{a} \right\rfloor \quad (i > 0), \]

It is proven that after several iterations, the sequence will stabilize at a constant \(x_N\). Formally, there exists an index \(j\) such that for all \(k, h \ge j\), \(x_k = x_h = x_N\). Your task is to output the Fusu iteration process up to (and including) the first occurrence of the stable constant. That is, output \(x_0, x_1, x_2, \dots, x_j\), where \(j\) is the smallest index satisfying \(x_j = x_{j+1}\).

inputFormat

The input consists of two space-separated positive integers: x0 and a (with a ≥ 2).

outputFormat

Output the iteration sequence starting from x0 and ending at the first occurrence of the stable constant, with each term separated by a space.

sample

10 3
10 4 2 1