Ankit_132

The Vowel Matrix

Jun 14th, 2023
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define ll     long long
  7. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  8. #define ff     first
  9. #define ss     second
  10. #define pb     push_back
  11. #define ppb    pop_back
  12.  
  13. int main()
  14. {
  15.     ios_base::sync_with_stdio(false);
  16.     cin.tie(NULL);
  17.     cout.tie(NULL);
  18.  
  19.     _test
  20.     {
  21.         int n, k;
  22.         cin>>n>>k;
  23.  
  24.         string s;
  25.         cin>>s;
  26.  
  27.         int MOD = 1e9 + 7;
  28.  
  29.         int cnt=0;
  30.         int x = 0;
  31.  
  32.         ll int ans = 1;
  33.  
  34.         for(auto e: s)
  35.         {
  36.             if(e=='a' || e=='e' || e=='i' || e=='o' || e=='u')
  37.             {
  38.                 cnt++;
  39.  
  40.                 if(cnt == k+1)
  41.                 {
  42.                     cnt = 1;
  43.                     (ans *= (x+1)) %= MOD;
  44.                 }
  45.  
  46.                 x = 0;
  47.             }
  48.             else
  49.                 x++;
  50.         }
  51.  
  52.         cout<<ans<<"\n";
  53.     }
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment