您的位置:首页 > 其它

hdu 5365 /BC 50CThe mook jong

2015-08-09 10:27 344 查看
简单dp 还是习惯 用记忆化搜素去写 以为这样不用初始化1 2 3的值 更优美

唯一tirck点是 数据在接近60时会爆int

#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include<set>
#include<stack>
#define bug puts("bugbugbug");
using namespace std;
typedef long long ll;
ll dp[100]={0};
ll dfs(int id)
{
    if(id<=0)return 1;
    if(dp[id])return dp[id];
     return dp[id]=dfs(id-1)+dfs(id-3);

}
int main()
{
    dfs(60);
    int n;
    while(~scanf("%d",&n))
    {
       printf("%I64d\n",dp
-1);
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: