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

建议使用的浏览器:

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

1381:Secret Code

题目描述
The Sarcophagus itself is locked by a secret numerical code. When somebody wants to open it, he must know the code and set it exactly on the top of the Sarcophagus. A very intricate mechanism then opens the cover. If an incorrect code is entered, the tickets inside would catch fire immediately and they would have been lost forever. The code (consisting of up to 100 integers) was hidden in the Alexandrian Library but unfortunately, as you probably know, the library burned down completely.

But an almost unknown archaeologist has obtained a copy of the code something during the 18th century. He was afraid that the code could get to the ``wrong people'' so he has encoded the numbers in a very special way. He took a random complex number B that was greater (in absolute value) than any of the encoded numbers. Then he counted the numbers as the digits of the system with basis B. That means the sequence of numbers an, an-1, ..., a1, a0 was encoded as the number X = a0 + a1B + a2B2 + ...+ anBn.

Your goal is to decrypt the secret code, i.e. to express a given number X in the number system to the base B. In other words, given the numbers X and Byou are to determine the ``digit'' a0 through an.
输入解释
The input consists of T test cases. The number of them (T) is given on the first line of the input file. Each test case consists of one single line containing four integer numbers Xr, Xi, Br, Bi (|Xr|,|Xi| <= 1000000, |Br|,|Bi| <= 16). These numbers indicate the real and complex components of numbers X and B, i.e. X = Xr + i.Xi, B = Br + i.Bi. B is the basis of the system (|B| > 1), X is the number you have to express.
输出解释
Your program must output a single line for each test case. The line should contain the ``digits'' an, an-1, ..., a1, a0, separated by commas. The following conditions must be satisfied:

  • for all i in {0, 1, 2, ...n}: 0 <= ai < |B|
  • X = a0 + a1B + a2B2 + ...+ anBn
  • if n > 0 then an <> 0
  • n <= 100

If there are no numbers meeting these criteria, output the sentence "The code cannot be decrypted.". If there are more possibilities:For the uniqueness of the answer,only print the one with smallest lexicographical order. For example, if the two sets are (4, 3, 18, 9) and (7, 1, 14, 8), then just output the first since its has smaller lexicographical order.
输入样例
4
-935 2475 -11 -15
1 0 -3 -2
93 16 3 2
191 -192 11 -12
输出样例
8,11,18
1
The code cannot be decrypted.
16,15

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

题目来源 Central Europe 1999

源链接: POJ-1381

最后修改于 2020-10-29T06:02:32+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 10000