随笔 - 4  文章 - 4  trackbacks - 0
<2008年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

常用链接

留言簿(1)

随笔分类(2)

随笔档案(4)

文章分类(1)

文章档案(1)

搜索

  •  

最新评论

  • 1. re: poj题目分类
  • 这个是我转载过来的而已啦,我也不强,你要想提高编程能力,做大量的题就行了。认准一个oj,不停的做题,做题,坚持两年,你就会很强了。@@潘翠敏
  • --我来我往
  • 2. re: poj题目分类
  • 如果可以,想请你帮我提高我的编程能力。
    我是潘翠敏。
    QQ:359110167
    目前是大一新生。
    谢谢啦!
  • --潘翠敏
  • 3. re: poj题目分类
  • 好厉害。佩服佩服!!!
  • --潘翠敏
  • 4. re: poj题目分类
  • 评论内容较长,点击标题查看
  • --我来我往

阅读排行榜

评论排行榜

Ackermann Function

Time Limit:5s Memory limit:32M
Accepted Submit:231 Total Submit:658

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:


Given m and n, your task is to compute the value of A(m,n)

Input

Each line of the input will have a 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
            

Original: chenyan



完全就是找规律而已!!m=0时,就是1,2,3,4,5,6,7,8,9……n+1
m=1时,就是2,3,4,5,6,7,8,9……n+2
m=2时,就是3,5,7,9,11,13,15……2*n+3
m=3时,等于A(2, A(n-1));这个用循环,一下子就能得出来了A(n)= 2*A(n-1)+3;
相当简单,但是一开始因为没找到规律,想了很多无用功,哎!!
posted on 2008-11-22 21:42 我来我往 阅读(1127) 评论(0)  编辑 收藏 引用 所属分类: acm

只有注册用户登录后才能发表评论。
相关文章:
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理