Submission

Status:
-----TTTTTTTTTTT

Score: 0

User: AungS8430

Problemset: Chocolate

Language: cpp

Time: 1.089 second

Submitted On: 2025-03-17 11:37:06

#include <bits/stdc++.h>
using namespace std;
#define mod 1e9+7


int N, K, c;
long long L, H;

int possible(vector<int> &chocolate, int left, int right, int remain) {
  long long possibility = 0;
  if (remain == 0) return left > right;
  if (left > right) return 0;
  for (int i = left; i <= right - remain + 1; i++) {
    int sum = 0;
    for (int j = left; j <= i; j++) {
      sum += pow(j - left, c) * chocolate[j];
    }
    if (sum <= H && sum >= L) {
      possibility += possible(chocolate, i + 1, N - 1, remain - 1);
    }
  }
  return possibility;
}

int main(void) {
  cin >> N >> K >> c;
  vector<int> chocolate(N);
  for (int i = 0; i < N; i++) {
    cin >> chocolate[i];
  }
  cin >> L >> H;
  cout << possible(chocolate, 0, N - 1, K) % (int) mod;
  return 0;
}