// Continue with Eddy
Problem DescriptionAs is known, Ackermann function plays an important role in the sphere of theoretical computer science. however, in the other hand, the dramatic fast increasing pace of the function caused the value of Ackermann function hard to calcuate.
Ackermann function can be defined recursively as follows:
Now Eddy Gives you two numbers: m and n, your task is to compute the value of A (m, n ). this is so easy problem, If you slove this problem, you will receive a prize (Eddy will invite you to hdu restaurant to have supper ).
InputEach line of the input will have two integers, namely m, n, where 0 <m <= 3.
Note that when m <3, n can be any integer less than 1000000, while m = 3, the value of n is restricted within 24.
Input is terminated by end of file.
OutputFor each value of m, n, print out the value of A (m, n ).
Sample Input
1 32 4
Sample Output
511
Authoreddy/******************** the first sight of this question is like recursion, then, according to the formula in the question, I found it difficult to find it. I first wrote a recursion, typed the table, and then, well, found the law ......
Tabulation. This is the real tabulation ......
If you see this table, you don't have to say the rule ......
*************************/
Code: <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + PHByZSBjbGFzcz0 = "brush: java;"> # include # Include # Include Using namespace std; int num [30]; int main () {int I, j, n, m; num [0] = 5; for (I = 1; I <30; I ++) num [I] = num [I-1] * 2 + 3; while (cin> m> n & m & n) {if (m = 1) printf ("% d \ n", n + 2); if (m = 2) printf ("% d \ n ", 2 * n + 3); if (m = 3) printf ("% d \ n", num [n]);} return 0 ;}