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

PROGRAMMING:series

Luz5年前 (2021-05-10)题库461
###Task description
Given a positive integer k (3 ≤ K ≤ 15), the sum of all the powers of K and all the powers of a finite number of mutually unequal K forms an increasing sequence. For example, when k = 3, the sequence is:
1, 3, 4, 9, 10, 12, 13,... (the sequence is actually: 3 ^ 0, 3 ^ 1, 3 ^ 0 + 3 ^ 1, 3 ^ 2, 3 ^ 0 + 3 ^ 2, 3 ^ 1 + 3 ^ 2, 3 ^ 0 + 3 ^ 1 + 3 ^ 2,...). Please find out the value of the n-th item of this sequence (expressed in decimal number).
For example, for k = 3, n = 100, the correct answer would be 981.
###Input format:
The input has only one line and is two positive integers separated by a space
k N
(the meaning of K and N is consistent with the above problem description, and 3 ≤ K ≤ 15, 10 ≤ n ≤ 1000).
###Output format:
The output is the calculation result, which is a positive integer (in all test data, the result does not exceed 2.1 * 10 ^ 9)( There should be no spaces or other symbols before integers).
###Input example:
```in
3 100
```
###Output example:
```out
nine hundred and eighty-one
```
###Title Source
Note: selected from RQNOJ website, online address: https://www.rqnoj.cn/problem/4






answer:If there is no answer, please comment