lightoj1006【记忆化搜索(我是这么叫)】

搜索的时候记录一下,注意要long long;

#include<cstdio>
#include<queue>
#include<map>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL mod=1e9+7;
 
bool vis[10010];
LL ff[10010];
 
LL a, b, c, d, e, f;
LL fn(int n)
{
    if(vis[n])
        return ff[n]%10000007;
    vis[n]=1;
    return ff[n]=(fn(n-1)+fn(n-2)+fn(n-3)+fn(n-4)+fn(n-5)+fn(n-6))%10000007;
}
int main()
{
    int n, caseno = 0, cases;
    scanf("%d", &cases);
    while( cases-- )
    {
        scanf("%lld %lld %lld %lld %lld %lld %d", &ff[0], &ff[1], &ff[2], &ff[3], &ff[4], &ff[5], &n);
        memset(vis,false,sizeof(vis));
        for(int i=0;i<=5;i++)
            vis[i]=true;
        printf("Case %d: %lld\n", ++caseno,fn(n)%10000007);
    }
    return 0;
}


转载于:https://www.cnblogs.com/keyboarder-zsq/p/6216790.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值