hdu1111 Secret Code ----复数+DFS
来源:互联网 发布:网络安全法培训ppt 编辑:程序博客网 时间:2024/06/08 15:49
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1111
一:原题内容
Problem Description
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.
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.
Input
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.
Output
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, print any of them.
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, print any of them.
Sample Input
4-935 2475 -11 -151 0 -3 -293 16 3 2191 -192 11 -12
Sample Output
8,11,181The code cannot be decrypted.16,15
二:分析理解
三:AC代码
1 0
- hdu1111 Secret Code ----复数+DFS
- 数论+dfs+复数除法剪枝 Secret Code hdu1111
- hdu1111 Secret Code
- hdu 1111 Secret Code dfs
- 【dfs】hdu 1111 Secret Code
- HDU 1111 Secret Code DFS 解题报告
- HDOJ1111 Secret Code(数论+DFS)
- hdu1111
- HDU 1111 - Secret Code (DFS + 一点数学 + 模拟)
- hdu 1111 Secret Code(复数·展开·深搜·输出)
- Top Secret Microsoft Code
- Android Secret Code
- Android Secret Code
- Android Secret Code
- hdu 1111 Secret Code
- 【HDU】 1111 Secret Code
- USACO2014FebruarySilver Secret Code
- HDU 1111 Secret Code 深搜
- HTTP Content-type 对照表___http://tools.jb51.net/table/http_content_type
- 查询数据库中为null字段的数据
- java中多线程介绍
- 网络编程知识(11)--DNS
- get请求中文乱码
- hdu1111 Secret Code ----复数+DFS
- Part2:Unity学习笔记十三 - Space Shooter(从视频最后一课向Done_Main.unity场景修改的过程)
- 选择排序-java实现
- linux系统swappiness参数在内存与交换分区间优化
- 如何定位和解决Andorid的内存溢出问题(大总结)
- 直播风口之下,视频社交会成为下一个流量平台吗?
- merge into语句
- 重载和重写(覆盖)的区别
- 20160511 GreenPlum8 数据倾斜对数据的影响