// 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. Quartz实例:quartz定时任务代码示例

    转自:http://www.blogchong.com/post/96.html quartz定时任务调度框架,使用实例. Job类://即实际调度任务实现 . package net.csdn.ed ...

  2. Maven与IDEA结合

    转自:https://blog.csdn.net/zzpzheng/article/details/49474671 1. 什么是 Maven,为什么要使用 Maven 而不是 Ant Maven简单 ...

  3. php mktime和strtotime

    本文章来给各位同学介绍一下利用php用strtotime或mktime指定日期数据(本周,上周,本月,上月,本季度)实例,希望对各位同学会有所帮助呀. strtotime定义和用法 strtotime ...

  4. python 下 excel,csv 文件的读写

    python 可以用利用xlrd 库读取数据excel数据,可以用xlwt写入excel数据,用csv 操作csv文件 xlrd xlwt  python 模块 官方链接  https://pypi. ...

  5. windows下flink示例程序的执行

    1.什么是flink Apache Flink® - Stateful Computations over Data Streams 2.启动 下载地址  我下载了1.7.2 版本  解压到本地文件目 ...

  6. 2.TinkPHP入门----控制器

    1.控制器创建 命名规则:控制器名称+Controller+.class.php, 例如GoodsController.class.php  UserController.class.php 控制器结 ...

  7. Hadoop系列之实验环境搭建

    实验环境基本配置 硬件:硬盘单节点50GB,1G内存,单核. 操作系统:CentOS6.4 64bit Hadoop:2.20 64bit(已编译) JDK:jdk1.7 磁盘分区: / 5GB /b ...

  8. delphi 用idhttp做web页面数据抓取 注意事项

    这里不讨论webbrowse方式了 .直接采用indy的 idhttp  Get post 可以很方便的获取网页数据. 但如果要抓取大量数据 程序稳定运行不崩溃就不那么容易了.这几年也做了不少类似工具 ...

  9. vuex的状态管理模式

    1.store.js Vuex 通过 store 选项,提供了一种机制将状态从根组件“注入”到每一个子组件中(需调用 Vue.use(Vuex)) state:存放数据. mutations:提交状态 ...

  10. 集成Bmob推送

    Write By lz:  转发请注明原文地址: http://www.cnblogs.com/lizhilin2016/p/6952217.html Lz 寄语: Bmob 奇葩推送, 大坑, 想要 ...