当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3741:Number System Converter

题目描述

ACM Lab produced a batch of number system converter recently. There are two kind of converter R1 and R2.

Given a parameter of P, converter R1's function is to transform the incoming P based integer into decimal number system. To simplify the design, R1 will not check that if the input is legal in P number system.

R2 is similar to R1, while acting an inverse function: convert a decimal number to Q(specified by R2) number system.

H.X.Q, a researcher of ACM Lab, made a circuit uses R1 and R2:

(The circuit works at an order R1, R2, R1, R2 ...)

And she found an interesting phenomenon: if P<Q then for any input sequence N0, after plenty of convention N1 will finally equal to N2. For example, P=2, Q=4, N0=321, finally, N1=N2=3.

H.X.Q is excited for her discover, and wants to know what N1 and N2 will finally be in this circuit when P, Q and N0 is given.

输入解释
The input contains several test cases. The first line of each test case specifies two number P and Q (1 < P < Q < 37), follow by N0 (the length of N0 is not larger than 5,000,000). Note that a digit larger than 9 is given in small letters, with 'a'=10, 'b'=11 ...
输出解释
For each test case, output a line standing for the final sequence in the circuit.
输入样例
2 4
321
输出样例
3

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3741

最后修改于 2020-10-29T07:09:50+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000 65536