【NOIP2005】【Luogu1052】过河

problem

占坑待填

solution

占坑待填???

codes

//交前%一下, 送你80分
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 30000010;
#define mod 23301
int l, s, t, m, a[maxn], f[maxn], cnt;
int main(){
    ios::sync_with_stdio(false);
    cin>>l>>s>>t>>m;
    for(int i = 1; i <= m; i++){
        int x;  cin>>x;  a[x%mod] = 1;
        if(s==t&&x%s==0)cnt++;//s==t的特判
    }
    if(s==t){cout<<cnt<<"\n";return 0;}
    for(int i = 1; i <= mod; i++)f[i]=0xffffff;
    for(int i = 1; i <= mod; i++){
        for(int j = s; j <= t; j++){
            if(i>=j)f[i] = min(f[i],f[i-j]+a[i%mod]);
        }
    }
    cout<<f[mod]<<"\n";
    return 0;
}
posted @ 2018-05-21 21:48  gwj1139177410  阅读(90)  评论(0编辑  收藏  举报
选择