-->
当前位置:首页 > 题库

PROGRAMMING:Calculate AAA

Luz5年前 (2021-05-10)题库426
Calculate s (n) = a + AA + AAA + AAAA +..., where a is a number. For example, n = 5, a = 2, s (5) = 2 + 22 + 222 + 2222 + 22222< br>
Tips: 2 × 10+2=?, twenty-two × 10+2=?
###Input format:
Two non negative integers, a and N, and a < = 9, n < = 8.
###Output format:
An integer representing s (n).
###Input example:
```in
3 5
```
###Output example:
```out
thirty-seven thousand and thirty-five
```







answer:If there is no answer, please comment
The difficulty of this problem is how to generate AAA. Suppose a is 2, we can find that 2 × 10 + 2 = 22, keep the temporary value of 22, then 22 × 10 + 2 = 222, then 222, then 222 × 10 + 2 = 2222, and so on< br>
Therefore, the cycle process becomes to use the law to generate a new number T and accumulate t into S.