http://acm.hdu.edu.cn/showproblem.php?pid=1165

不看题解,使劲找规律,应该是可以找到的,就是费时间!

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
#include <stdio.h>
#include <string.h>
long fun(long m,long n)
{if(n==0)return fun(m-1,1);else if(m==0)return n+1;else if(m==1)return n+2;else if(m==2)return 2*n+3;else if(m==3)return fun(m,n-1)*2+3;
}
int main()
{long n,m,i,j;while(scanf("%ld%ld",&n,&m)!=EOF){//if(n==3)m==24;//else m=n;printf("%ld\n",fun(n,m));}return 0;
}

转载于:https://www.cnblogs.com/ccccnzb/p/3419272.html

hdu 1165 坑爹找规律题相关推荐

  1. 笔试逻辑智力题找规律题总结1

    1.     3,3/2,1,3/4,(),1/2 解析:分子为3,分母为项数         3/1,3/2,3/3,3/4,3/5,3/6 答案:3/5   2.    3/2,5/8,7/24, ...

  2. 笔试逻辑智力题找规律题总结2

    1.    在这一系列表盘中,应该出现的是下一个表盘的哪个? 解析:黑针每次顺时针走2格,白针每次逆时针走2格 答案:第3个     2.    32, 27, 16,9,8,(),4,1 解析:   ...

  3. hdu 4148 Length of S(n) (坑爹的规律题)

    题意不明确就是让你根据前面的几个式子来找规律,找了我足足两个小时啊!!有点坑!! S(1)=1,  S(2)=11,由S(1)从左往右1个1,所以为11: S(3)=21,由S(2)从左往右2个1所以 ...

  4. Codeforces 959 E. Mahmoud and Ehab and the xor-MST 思路:找规律题,时间复杂度O(log(n))

    题目: 解题思路 这题就是0,1,2-n-1总共n个数字形成的最小生成树. 我们可以发现,一个数字k与比它小的数字形成的异或值,一定可以取到k与所有正整数形成的异或值的最小值. 要计算n个数字的情况我 ...

  5. 埃森哲杯第十六届上海大学程序设计联赛春季赛暨上海高校金马五校赛 F- 1 + 2 = 3? (好难的找规律题)

    斐波那契真的牛掰 题目链接 题目描述: 小Y在研究数字的时候,发现了一个神奇的等式方程 ,他屈指算了一下有很多正整数x满足这个等式,比如1和2,现在问题来了,他想知道从小到大第N个满足这个等式的正整数 ...

  6. 【CodeForces - 1027B 】Numbers on the Chessboard (没有营养的找规律题,无聊题)

    题干: You are given a chessboard of size n×nn×n. It is filled with numbers from 11 to n2n2 in the foll ...

  7. 【笔试/面试】—— 数学找规律题

    所谓找规律其实是寻找一个函数 f(x)f(x),一个映射. 数字敏感度 (1)数列是否可以转化为:某数的平方 + 另外一项的形式 5=22+110=32+127=52+2 5=2^2+1\\10=3^ ...

  8. hdu 4279 Number (找规律)

    http://acm.hdu.edu.cn/showproblem.php?pid=4279 题意: 给出a,b两个数,1<=a<=b 如果a,b不互质,且a%b != 0则说明a是b的特 ...

  9. 找规律题(面试+练脑子)

    图形为主--图像相似(都含有方框.圆形一类的)--找相同部分之间联系(前一个图形中含有后一个图形的什么东西之类的)---找转弯关系 eg.1 从所给四个选项中,选择最合适的一个填入问号处,使之呈现一定 ...

最新文章

  1. 十分钟学习自然语言处理概述
  2. 组织应该采用集中式发电机吗?
  3. paho mqtt 在某平台sdk应用上发送数据定时器超时问题
  4. 北理工2017年爬虫目录
  5. animate.css(第三方动画使用方法)
  6. 智能安防新时代:用户、SI、设备制造商要做什么?
  7. Knockout中ko.utils中处理数组的方法集合
  8. 在不使用{}时,else执行到哪里结束
  9. Microsoft Expression blend 3 新功能简介
  10. HDU 2014 - 青年歌手大奖赛_评委会打分
  11. 在excel中如何筛选重复数据_EXCEL里如何快速统计重复的次数?
  12. 敏捷教练如何辅导发布计划的制定之开展行动
  13. Java - 数组常用方法
  14. 《Kotlin极简教程》第1章 Kotlin简介
  15. 谢文的yiqi有戏没?
  16. Linux系统信息收集
  17. 什么是Kurento
  18. css画出wifi图标,css3实现wifi信号逐渐增强效果实例
  19. 基于OpenCV的鱼眼相机畸变矫正(含代码)
  20. 解决:Error resolving template [/xxx], template might not exist or might not be accessible by any of th

热门文章

  1. 《程序员面试金典》解题目录(更新完毕)
  2. POJ 1276 ATM凑钱(动态规划)(未解答)
  3. python的运行环境_python-运行环境配置-1
  4. j2ee和mysql怎么连接_J2EE数据库连接不再烦恼
  5. hive 创建表_2min快速了解,Hive内部表和外部表
  6. 操作系统是计算机的什么管理者,操作系统是计算机资源的管理者
  7. word里双横线怎么打_美人计 | 精致打工人秀智,教你内双怎么化
  8. 动态规划 - Floyd算法求最短路径 - (Matlab建模)
  9. 为了养成NLP卷王,我画了一张路线图
  10. 卫星系统——酒店后端全链路日志收集工具介绍