DP~青蛙过河(hrbust1186)

 

#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;

}

 

posted @ 2016-04-12 20:23  799  阅读(168)  评论(0编辑  收藏  举报