Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- ios_base::sync_with_stdio(false);
- string A, B;
- int repeat;
- cin >> A >> B >> repeat;
- string s = "";
- for(int i = 0; i < repeat; i++) {
- s += A;
- if(A.size() > 0) {
- A.erase(A.end() - 1);
- }
- }
- vector<bool> alpha(26, false);
- for(int i = 0; i < B.size(); i++) {
- alpha[B[i] - 'a'] = true;
- }
- int result = 0;
- for(int i = 0; i < s.size(); i++) {
- int sum = 0;
- for(int j = i; j < s.size(); j++) {
- sum += alpha[s[j] - 'a'];
- result += sum;
- }
- }
- cout << result << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement