Submission

Status:

PPPPPTTTTTTTTTTT

Subtask/Task Score:

50/160

Score: 50

User: devilpoohs

Problemset: Chocolate

Language: cpp

Time: 1.097 second

Submitted On: 2026-03-07 12:41:53

#include<bits/stdc++.h>
using namespace std;
const int N=5e3+10;
const int mod=1e9+7;
int n,c,K,l,h;;
int ar[N];
int powi[N];
int think(int i,int k){
    if(i==n){
        
        if(k==0){
            // cout<<'a';
            return 1;
        } 
        return 0;
    }
    int cnt=0;
    int sum=0;
    for(int j=i,mul=0;j<n;j++,mul++){
        sum+=(ar[j]*powi[mul]);
        if(sum>h) break;
        // cout<<i<<','<<j<<','<<sum<<'\n';
        if(k>=1 and sum>=l){
            // cout<<j+1<<' '<<k-1;
            cnt+=think(j+1,k-1)%mod;
            cnt%=mod;
        }
    }
    cnt%=mod;
    return cnt;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>K>>c;
    for(int i=0;i<n;i++){
        cin>>ar[i];
        powi[i]=1;
        for(int j=0;j<c;j++){
            powi[i]*=i;
            powi[i]%=mod;
        }
        // cout<<i<<','<<powi[i]<<'\n';
    }
    cin>>l>>h;
    cout<<think(0,K);
    return 0;
}
/*
8 3 2
7 9 1 3 3 6 2 9
4 64
*/