// Eddy 继续

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
 
Author
eddy
 
/********************

看到哦这个题的第一眼感觉像是递推,然后依据那个题目中的公式发现不太好找。就先写了一个递归。打表,然后。恩。找规律……

打表,这才是真正的打表啊……

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ3JheV8xNTY2/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

看到这个表,规律就不用我说了吧……

*************************/

Code:

#include <iostream>
#include <string.h>
#include <stdio.h>
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;
}

hdu 1165 Eddy&#39;s research II(数学题,递推)的更多相关文章

  1. HDU1165: Eddy's research II(递推)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1165 果断不擅长找规律啊,做这种题静不下心来. Ackermann function can be def ...

  2. HDU 1164 Eddy&#39;s research I【素数筛选法】

    思路:将输入的这个数分成n个素数的相乘的结果,用一个数组存储起来.之后再输出就能够了 Eddy's research I Time Limit: 2000/1000 MS (Java/Others)  ...

  3. HDU 1165 Eddy's research II(给出递归公式,然后找规律)

    - Eddy's research II Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  4. HDU 5950 - Recursive sequence - [矩阵快速幂加速递推][2016ACM/ICPC亚洲区沈阳站 Problem C]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5950 Farmer John likes to play mathematics games with ...

  5. HDU 1165 Eddy's research II (找规律)

    题意:给定一个表达式,然后让你求表达式的值. 析:多写几个就会发现规律. 代码如下: #pragma comment(linker, "/STACK:1024000000,102400000 ...

  6. HDU 1165 Eddy's research II

    题意:已知,求A(m, n). 分析:根据样例模拟一下过程就可以找出递推关系. #include<cstdio> #include<cstring> #include<c ...

  7. hdu 1162 Eddy&#39;s picture (Kruskal算法,prim算法,最小生成树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1162 [题目大意] 给你n个点的坐标,让你找到联通n个点的一种方法.保证联通的线路最短,典型的最小生成 ...

  8. HDU-1165-Eddy&#39;s research II

    这个事实上是一个递归题.题目非常easy.m的数非常小.分三种情况.算一下.就能够直接把公式算出来. 当然,也能够用dp做: #include<iostream> #include< ...

  9. hdu 1207 汉诺塔II (DP+递推)

    汉诺塔II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

随机推荐

  1. 【CQOI 2009】 余数之和

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1257 [算法] k mod i = k - [k / i] * i 所以 (k mo ...

  2. Lucene中Analyzer语句分析

    Lucene中Analyzer语句分析,利用lucene中自带的词法分析工具Analyzer,进行对句子的分析. 源代码如下: package com.test; import java.io.IOE ...

  3. 本地文件SVN和 vs svn 插件的使用!!

    比如:客服端是用的TortoiseSVN-1.7.7.22907-x64-svn-1.7.5.msi 里面svn 版本是1.7.5 vs里的插件 也需要svn 版本是1.7.5 对应的AnkhSvn- ...

  4. hihoCoder挑战赛32

    Rikka with Sequence V 构造 #pragma comment(linker, "/STACK:102400000,102400000") #include< ...

  5. MemCached总结一:Unbutu操作系统下memcached服务器安装和telnet方式连接memcache

    1.在Unbutu上安装memcached服务器 sudo apt-get update sudo apt-get install memcached 2. 确认memcached是否安装 要确认me ...

  6. HttpServletRequest二三事

    缘由 在项目中,闲来无聊写了个bug LOGGER.info("前端请求,request:{}",JSON.toJSONString(request)); 好像还好是吧,来我告诉你 ...

  7. HTML 引入 CSS、JS 的三种方式

    描述部分按 CSS 来的,其实 JavaScript 也一样,具体区别看代码 外部样式表 当样式需要被应用到很多页面的时候,外部样式表将是理想的选择.使用外部样式表,你就可以通过更改一个文件来改变整个 ...

  8. python简单的输入与输出

    1 首先利用python完成简单的输出,运行如下: python和c语言类似,但又有所不同,python开发快,语言简洁,我是这样对比学的 输出:print+空格+'要输出的内容',一定要是英文状态下 ...

  9. JS 马托货物

    大马驮2石粮食,中马驮1石粮食,两头小马驮一石粮食,要用100匹马,驮100石粮食,该如何调配? <!DOCTYPE html> <html> <head> < ...

  10. priority_deque作为Timer时间队列底层容器的一些思考

    https://www.bbsmax.com/A/D854VkZxzE/ 设置底层容器可以分离出两个逻辑上独立的问题: >如何存储构成优先级队列(容器)的实际元素,以及>如何组织这些元素以 ...