Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int getTranformedLength(string s, int t)
- {
- long long mod = 1e9+7;
- vector<long long> v(26, 0);
- for (auto &i : s)
- {
- v[i - 'a']++;
- }
- long long ans = 0;
- long long last = 0;
- for (int i = 0; i < t; i++)
- {
- for (int j = 0; j < 26; j++)
- {
- if (j != 25)
- {
- long long val = v[j];
- v[j] = last;
- last = val;
- }
- else
- {
- long long val = v[j];
- v[0] += val;
- v[0] %= mod;
- v[1] += val;
- v[1] %= mod;
- v[j] = last;
- last = 0;
- }
- }
- }
- for (int i = 0; i < 26; i++)
- {
- ans = (ans + v[i]) % mod;
- }
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement