rembocoder

Untitled

May 14th, 2023
636
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define int int64_t
  4.  
  5. using namespace std;
  6.  
  7. int mod = 1e9 + 7;
  8.  
  9. int32_t main() {
  10.     ios_base::sync_with_stdio(false);
  11.     int n, k;
  12.     cin >> n >> k;
  13.     string s;
  14.     cin >> s;
  15.     vector<int> dp(n);
  16.     dp[0] = 1;
  17.     for (int i = 1; i < n; i++) {
  18.         if (s[i - 1] == 'X') {
  19.             continue;
  20.         }
  21.         for (int j = 1; j <= k && j <= i; j++) {
  22.             (dp[i] += dp[i - j]) %= mod;
  23.         }
  24.     }
  25.     cout << dp[n - 1] << '\n';
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment