#P2558. [AHOI2002] 网络传输
[AHOI2002] 网络传输
Description
In computer networks, all data are transmitted in binary form. However, when transmitting large data, directly sending its binary representation often requires too many bits. For example, transmitting needs an -bit binary number. Therefore, Xiao Keke proposed an idea for optimizing data transmission and plans to test it.
The idea is: arrange in increasing order the sequence consisting of all positive integer powers of , as well as sums of any number of pairwise distinct powers of . For example, when , the first terms of are , , , , , , .
If a number is the -th term of the sequence , then one can represent by transmitting the two numbers and . Since the relatively small numbers and can represent a very large number, this can theoretically reduce the number of bits transmitted.
Now Xiao Keke asks you to write a program to compute the number represented by the received and .
Input Format
A single line contains two positive integers and , with , .
Output Format
Output the answer in one line (the number of digits does not exceed ).
3 2
3
3 7
13
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号