首页 > 其他 > 详细

DP~青蛙过河(hrbust1186)

时间:2016-04-12 20:56:21      阅读:190      评论:0      收藏:0      [点我收藏+]

技术分享

 

#include<stdio.h>
#include<string.h>
int DP[100000];//表示相应的位置的踩到的石子
int l,s,t,n;
int main()
{

    while(~scanf("%d%d%d%d",&l,&s,&t,&n))
   {
        memset(DP,0,sizeof(DP));
        for(int i=1; i<=n; i++)//输入与初始化
        {
            int temp;
            scanf("%d",&temp);
            DP[temp]=1;
        }
        for(int i=l-t; i>=0; i--)//找
        {
            int temp=DP[i+s];
            for(int j=s+1; j<=t; j++)
            {
                if(DP[i+j]<temp)//更新
                    temp=DP[i+j];
            }
           DP[i]+=temp;
        }
        printf("%d\n",DP[0]);
    }
    return 0;

}

 

DP~青蛙过河(hrbust1186)

原文:http://www.cnblogs.com/sxy-798013203/p/5384177.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!