HDU-1165-Eddy's research II

这个事实上是一个递归题。题目非常easy。m的数非常小。分三种情况。算一下。就能够直接把公式算出来。

当然,也能够用dp做;

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#define LL long long
using namespace std;
/*
    自己收敲一下。递推就能够直接出来答案;
*/
int main()
{
    int n,m;
    while(~scanf("%d%d",&m,&n)){
        switch(m){
            case 1:printf("%d\n",n+2);break;
            case 2:printf("%d\n",2*n+3);break;
            case 3:printf("%lld\n",(LL)(2<<(n+2))-3);break; //  好吧,我递推出来,是2^(n+3)-3,位运算的时候得注意了是2<<(n+2)-3。
        }
    }
    return 0;
}

HDU-1165-Eddy's research II

时间: 2024-08-19 01:11:28

HDU-1165-Eddy&#39;s research II的相关文章

hdu 1165 Eddy&amp;#39;s research II(数学题,递推)

// 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

HDU 1165 Eddy&#39;s research II

Eddy's research II Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3970    Accepted Submission(s): 1459 Problem Description As is known, Ackermann function plays an important role in the sphere

hdu 1165 Eddy&#39;s research II(数学题,递推)

// 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

HDU 1165 Eddy&#39;s research II (推公式)

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 Problem Description As is known, Ackermann function plays an important role in the sphere

HDU 1165 Eddy&#39;s research II(递推)

坑了我好久,乍看很简单,记忆化搜索结果爆栈,然后改成递推之后WA . 后来发现,是在计算m=3的数据时出现了错误,因为当m=3时,即使n很小,结果也会很大,所以无法利用m=2时的结果递推,要怎么办呢?  将m=2的结果打印出来可以发现这是一个等差数列,通项为S(n) = 2*n + 3; 这有什么用呢? 我们可以发现,当 m=3时由递推式可以写成A(m,n) = A(2,A(m,n-1)) = 2*A(m,n-1) + 3; 所以只要知道了A(3,0),我们就能递推出所有m=3时的值了 . 细节

HDU 1165 Eddy&#39;s research II(给出递归公式,然后找规律)

- Eddy's research II Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description As is known, Ackermann function plays an important role in the sphere of theoretical computer science. However, in the other h

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

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1162 [题目大意] 给你n个点的坐标,让你找到联通n个点的一种方法.保证联通的线路最短,典型的最小生成树问题. 方法一 . 通过不断找到最小的边来找到终于结果. Kruskal 算法 #include <iostream> #include <algorithm> #include <cstdio> #include <cmath> using namespac

HDU1165: Eddy&#39;s research II(递推)

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1165 果断不擅长找规律啊,做这种题静不下心来. Ackermann function can be defined recursively as follows: 递推如上图, 0<m<=3,0<=n<=1000000,,当m==3时,n>=0&&n<=24. 首先发现a(0,i)=i+1; 另外n==0时,a(1,0)=a(0,1)=2; 当m==1,n>

hdu 1164 Eddy&#39;s research I

1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<string> 5 #include<cmath> 6 #include<algorithm> 7 using namespace std; 8 #define MAX 65535 9 int prime[MAX+5]; 10 bool vis[MAX+5]; 11 int index=0; 1