题目是这样的:
Description
Each natural number is the sum of some powers of two. For example: 37=2^5+2^2+2^0. Now, we say a^b can be indicated like this: a(b), so 37=2(5)+2(3)+2(0). 5=2(2)+2(0), 3=2+2(0), so in the end 37=2(2(2)+2(0))+2(2)+2(0). We call this 0-2 Indicating Method.
Input
Each line contains only a number N(N<32767), the input will be end by a zero.
Output
Please use 0-2 Indicating Method to indicate each number, each for one line. There is no extra blank in each line.
Sample Input
37
0
Sample Output
2(2(2)+2(0))+2(2)+2(0)
就是要把一个数转化成用2^0和2^2表示的式子。
我的程序它总是说Output Limit Exceeded
而且这个题目很模糊,比如说,根据题意,8可以有两种答案:
2(2(0)+2(0)+2(0))
2(2)+2(2)
其实我觉得还可以2(0)加8个这样等等(不过这些不是最优解)
那么,这题到底应该怎么做才好呢?
请告诉我吧,谢谢了。