HDU 1165 公式推导题
题目链接:
acm.hdu.edu.cn/showproblem.php?pid=1165
Eddy's research II
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5656 Accepted Submission(s): 2045
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).
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.
#include<bits/stdc++.h>
using namespace std;
int f(int n)
{
int s=1;
for(int i=1;i<=n;i++)
{
s=s*2;
}
return s;
}
int solved(int m,int n)
{
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 f(n+3)-3;
}
}
int main()
{
int n,m;
while(~scanf("%d %d",&m,&n))
{
printf("%d\n",solved(m,n));
}
return 0;
}
HDU 1165 公式推导题的更多相关文章
- HDU-1042-N!(Java大法好 && HDU大数水题)
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Subm ...
- HDU 自动刷题机 Auto AC (轻轻松松进入HDU首页)
前言: 在写这篇文章之前,首先感谢给我思路以及帮助过我的学长们 以下4篇博客都是学长原创,其中有很多有用的,值得学习的东西,希望能够帮到大家! 1.手把手教你用C++ 写ACM自动刷题神器(冲入HDU ...
- hdu 5326(基础题) work
http://acm.hdu.edu.cn/showproblem.php?pid=5326 一道水题,题目大意是在公司里,给出n个员工和目标人数m,然后下面的n-1行是表示员工a管理b,问在这些员工 ...
- 【转载】 HDU 动态规划46题【只提供思路与状态转移方程】
1.Robberies 连接 :http://acm.hdu.edu.cn/showproblem.php?pid=2955 背包;第一次做的时候把概率当做背包(放大100000倍化为整数) ...
- hdu 5162(水题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...
- hdu 4908(思路题)
BestCoder Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- hdu 1165 Eddy's research II(数学题,递推)
// Eddy 继续 Problem Description As is known, Ackermann function plays an important role in the sphere ...
- 2015ICPC chanchun HDU 5534 (树形题转换完全背包)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5534 题意:给你n个点,让你加上n-1条边使他变成一棵树,题目首先给你a[1] a[2].....a[n- ...
- HDU 5391 水题。
E - 5 Time Limit:1500MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
随机推荐
- MySQL之多表查询练习
一.表格 表一 emp 表二 dept 表三 salgrade; 表四 年度利润表 二.习题 1. 查出至少有一个员工的部门.显示部门编号.部门名称.部门位置.部门人数. 2. 列出所有员工的姓名及 ...
- NOI 2016 区间 解题报告
题目描述 在数轴上有 n个闭区间 [l1,r1],[l2,r2],...,[ln,rn].现在要从中选出 m 个区间,使得这 m个区间共同包含至少一个位置.换句话说,就是使得存在一个 x,使得对于每一 ...
- CSS 伪类(下)结构性伪类\UI伪类\动态伪类和其他伪类 valid check enable child required link visit
伪类选择器汇总伪类选择器有4种, 结构性伪类\UI伪类\动态伪类和其他伪类. 具体如下 结构性伪类选择器结构性伪类选择器它能够根据元素在文档中的位置选择元素, 这类元素都有个前缀":&q ...
- C#基础-for循环执行顺序
for(表达式1;表达式2;表达式3) {循环体} 执行顺序:1-表达式1赋值 2-判断表达式2是否为真 3-表达式2如果为否跳出for循环,如果为真执行循环体 4-执行表达式3 5-判断表达式2继续 ...
- Install Java JDK JRE on Ubuntu/Debian with Apt-Get
Introduction As a lot of articles and programs require to have Java installed, this article will gui ...
- Angular1.x 基础总结
官方文档:Guide to AngularJS Documentation w3shools angularjs教程 wiki <AngularJS权威教程> Introd ...
- oracle基础之游标的理解与使用
关于游标,首先要知道游标的定义. 游标,是内存中的一款区域,用来存放select的结果集 游标用来处理从数据库中检索的多行记录(使用select语句).利用游标,程序可以逐个的处理和遍历一次索引返回的 ...
- leetcode BFS
1. word ladder class Solution { public: int ladderLength(string beginWord, string endWord, unordered ...
- [翻译] ABCIntroView
ABCIntroView ABCIntroView is an easy to use onboarding which allows you to introduce your users to t ...
- XmlIgnore的使用
public class Group { public string GroupName; [XmlIgnore] public string Comments; } 在序列化时,其结果如下所示 &l ...