In mathematics, ackermann function is a special kind of recursive function that is not primitive recursive,

which means that you can not re-write the function into iterative form.

Below is the definition of ackermann function:

$A(n, m) =

\begin{align}

\begin{cases}

m + 1 & \textrm{ , if n = 0} \\

A(n - 1, 1) & \textrm{ , if m = 0} \\

A(n - 1, A(n, m - 1)) & \textrm{ , otherwise} \\

\end{cases}

\end{align}

$

Given n and m, please write a program to calculate the value of $A(n, m)$.

two integers $n$ and $m$ ($0 \leq n \leq 3$, $0 \leq m \leq 10$), separated by a space

an integer which represents $A(n, m)$

2 3

9

No. | Testdata Range | Score |
---|---|---|

1 | 0~4 | 100 |

No. | Time Limit (ms) | Memory Limit (KiB) | Output Limit (KiB) | Subtasks |
---|---|---|---|---|

0 | 1000 | 65536 | 65536 | |

1 | 1000 | 65536 | 65536 | |

2 | 1000 | 65536 | 65536 | |

3 | 1000 | 65536 | 65536 | |

4 | 1000 | 65536 | 65536 |