+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
Shayan, a computer engineering student at the University of Tehran with a great passion for mathematics, is a little bit lazy and always makes the minimum effort to solve every task he comes up with. In the first few weeks of school, Shayan’s little cousin Hadi has a few problems with his math exercises and asks Shayan to help him. These math exercises are all about the sum of digits of a number.
Shayan obviously teaches his little cousin how to solve them, but he also assigns Hadi some exercises to make sure that he really understands the concept. Due to his laziness, Shayan doesn’t want to think of some numbers to use. To save time, he will use a recursive strategy to create $n$ exercises of increasing difficulty that Hadi will use to practice.
The $n$ exercises are defined by Shayan as follows: First, we define an initial exercise made out of a single digit $s_1 = d$. Then, we define the remaining exercises with the following formula:
$$s_n = s_{n-1} * n * s_{n-1}$$
Where $*$ is the operation of concatenation, for example $12 * 34 * 56 = 123456$.
Now that the exercises are ready, help Shayan verify Hadi’s solutions by writing an algorithm that, given the initial digit $d$ and the index $n$ of the exercise, calculates the correct answer, i.e. the sum of the digits of $s_n$.
# input
The first line contains two integers: $d$ and $n$, respectively, the initial digit defined by Shayan and the index of the element of the sequence for which Shayan wants to calculate the sum of the digits.
$$0 \leq d \leq 9$$
$$1 \leq n \leq 60$$
# output
You need to write a single line containing the sum of digits of $s_n$.
It is guaranteed that the result will fit in a normal signed 64-bit integer variable. It will
definitely overflow a 32-bit variable.
# example
### sample input 1
```
1 3
```
### sample output 1
```
11
```
### sample input 2
```
3 11
```
### sample output 2
```
6104
```
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.