#P1062. [NOIP 2006 普及组] 数列
[NOIP 2006 普及组] 数列
Description
Given a positive integer (), form an increasing sequence consisting of all powers of and all sums of finitely many distinct powers of . For example, when , the sequence is:
(This sequence is in fact: .)
Please compute the value of the -th term of this sequence and output it in base (decimal).
For example, for and , the correct answer is .
Input Format
Two positive integers and separated by a space (, ).
Output Format
A single positive integer. Do not print any spaces or other symbols before the integer.
3 100
981
Hint
NOIP 2006 Junior Problem 4.
Translated by ChatGPT 5
京公网安备 11011102002149号