the same idea in C++ . Accepted with time 576ms

class Solution {
public:
int getMaxRepetitions(string s1, int n1, string s2, int n2) {
int k = 0;
int count = 0;
for(int i = 0; i < n1; i++) {
for(int j = 0; j < s1.size();) {
if(s1[j] == s2[k]) {
j++;
k++;
if(k == s2.size()) {
k = 0;
count += 1;
}
}else {
j++;
}
if(j==s1.size() && k == 0) {
return int(n1 * 1.0 / (i+1) * count / n2);
}
}
}
return count / n2 ;
}
};