Score : $300$ points
For an integer $x$ not less than $0$, we define $g_1(x), g_2(x), f(x)$ as follows:
For example, we have $g_1(314)=431$, $g_2(3021)=123$, $f(271)=721-127=594$. Note that the leading zeros are ignored.
Given integers $N, K$, find $a_K$ in the sequence defined by $a_0=N$, $a_{i+1}=f(a_i)\ (i\geq 0)$.
Input is given from Standard Input in the following format:
$N$ $K$
Print $a_K$.
314 2
693
We have:
1000000000 100
0
We have:
6174 100000
6174