前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >HDUOJ----1165Eddy's research II

HDUOJ----1165Eddy's research II

作者头像
Gxjun
发布2018-03-22 11:09:49
4840
发布2018-03-22 11:09:49
举报
文章被收录于专栏:ml

Eddy's research II

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2706    Accepted Submission(s): 985

Problem Description

As 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).

Input

Each 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.

Output

For each value of m,n, print out the value of A(m,n).

Sample Input

1 3

2 4

Sample Output

5

11

代码:

代码语言:javascript
复制
 1 /*@coder龚细军*/
 2 #include<stdio.h>
 3 int Ackermann(int m,int n)
 4 {
 5          if(m==0) return n+1;
 6     else if(m==1) return n+2;
 7     else if(m==2) return 2*n+3;
 8     else if(m==3) return (1<<n+3)-3;
 9 }
10 int main()
11 {
12     int n,m;
13     while(~scanf("%d%d",&m,&n))
14     {
15         printf("%d\n",Ackermann(m,n));
16     }
17     return 0;
18 }
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2013-12-23 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Eddy's research II
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档