【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<<"
";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]<<"
";
    return 0;
}
原文地址:https://www.cnblogs.com/gwj1314/p/9444849.html