您的位置:首页 > 其它

HDU 1165 Eddy's research II (推公式)

2014-08-07 00:01 531 查看

Eddy's research II

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


[align=left]Problem Description[/align]
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:

#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
using namespace std;
__int64 A(int m,int n)
{
if(m==0)  return n+1;
if(m==1)  return n+2;
if(m==2)  return 2*n+3;
if(m==3)  return (1<<(n+3))-3;
}
int main()
{
int m,n;
while(scanf("%d %d",&m,&n)!=EOF)
{
printf("%I64d\n",A(m,n));
}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: