fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4. const int mod = 1000000007;
  5. int N, K, X, s[2509], dp[5009][10009];
  6. int main() {
  7. dp[0][1] = 1;
  8. for (int i = 1; i <= 5000; i++) {
  9. int sum = 0;
  10. for (int j = 1; j <= 10000; j++) {
  11. int lim = i + i % 2;
  12. sum += dp[i - 1][j - 1];
  13. if (j - lim >= 1) sum -= dp[i - 1][j - lim - 1];
  14. if (sum >= mod) sum -= mod;
  15. if (sum < 0) sum += mod;
  16. dp[i][j] = sum;
  17. if (j <= i + 1) dp[i][j]++;
  18. if (dp[i][j] >= mod) dp[i][j] -= mod;
  19. }
  20. }
  21. cin >> N >> K >> X;
  22. for (int i = 0; i < K; i++) cin >> s[i];
  23. int ret = 1;
  24. for (int i = 0; i < K - 1; i++) ret = 1LL * ret * (X - i >= 1 ? dp[2 * X - 2 * i - 1][s[i + 1] - s[i]] : 0) % mod;
  25. cout << ret << endl;
  26. return 0;
  27. }
Success #stdin #stdout 0.22s 211904KB
stdin
7 2 3
0 7
stdout
55