#C4187. Super Digit
Super Digit
Super Digit
You are given a number n as a string and an integer k. Construct a new number P by concatenating n with itself k times. In mathematical notation, this can be written as:
$$P = \underbrace{n \| n \| \cdots \| n}_{k \text{ times}} $$The super digit of a number is defined recursively as follows:
$$\text{superdigit}(x)=\begin{cases} x, & \text{if } x < 10 \\ \text{superdigit}\Big(\sum_{i} (\text{digit}_i)\Big), & \text{otherwise} \end{cases} $$Your task is to compute the super digit of the number P formed by concatenating n k times.
inputFormat
The input is read from stdin and consists of a single line containing a string n and an integer k separated by a space.
Example:
148 3
outputFormat
Output to stdout the super digit of the constructed number P as a single integer.
Example:
3## sample
123 1
6
</p>