Solution
C++ []\nclass Solution {\npublic:\n    int getMaxRepetitions(string s1, int n1, string s2, int n2) {\n        vector<int> rapport(102,-1);\n        vector<int> 
```C++ []\nclass Solution {\npublic:\n    int getMaxRepetitions(string s1, int n1, string s2, int n2) {\n        vector<int> rapport(102,-1);\n        vector<int> rest(102,-1);\n        int b=-1;int posRest=0;int rap=0;\n        int last=-1;\n        rapport[0]=rest[0]=0;\n        for(int i=1;i<=s2.size()+1;i++){\n            int j;\n            for(j=0;j<s1.size();j++){\n                if(s2[posRest]==s1[j]){\n                    posRest++;\n                    if(posRest==s2.size()){\n                        rap++;\n                        posRest=0;\n                    }\n                }\n            }\n            for(int k=0;k<i;k++){\n                if(posRest==rest[k]){b=k;last=i;break;}\n            }\n            rapport[i]=rap;rest[i]=posRest;\n            if(b>=0)break;\n        }\n        int interval=last-b;\n        if(b>=n1)return rapport[n1]/n2;\n        return ((n1-b)/interval*(rapport[last]-rapport[b])+rapport[(n1-b)%interval+b])/n2;  }\n};\n```\n\n```Python3 []\nclass Solution(object):\n    def getMaxRepetitions(self, s1, n1, s2, n2):\n        start = {}\n        s1_round, s2_round, s2_idx = 0, 0, 0\n        while s1_round < n1:\n            s1_round += 1\n            for ch in s1:\n                if ch == s2[s2_idx]:\n                    s2_idx += 1\n                    if s2_idx == len(s2):\n                        s2_round += 1\n                        s2_idx = 0\n            if s2_idx in start:\n                prev_s1_round, prev_s2_round = start[s2_idx]\n                circle_s1_round, circle_s2_round = s1_round - prev_s1_round, s2_round - prev_s2_round\n                res = (n1 - prev_s1_round)\n                left_s1_round = (n1 - prev_s1_round) % circle_s1_round + prev_s1_round\n                for key in start:\n                    val = start[key]\n                    if val[0] == left_s1_round:\n                        res += val[1]\n                        break\n                return res \n            else:\n                start[s2_idx] = (s1_round, s2_round)\n        return s2_round\n```\n\n```Java []\nclass Solution {\n    public int getMaxRepetitions(String s1, int n1, String s2, int n2) {\n         int l1 = s1.length(), l2 = s2.length();\n        int[] next = new int[l2 + 1];\n        int[] count = new int[l2 + 1];\n        int cnt = 0, p = 0;\n        for (int i = 0; i < n1; i++) {\n            for (int j = 0; j < l1; j++) {\n                if (s1.charAt(j) == s2.charAt(p)) {\n                    p++;\n                }\n                if (p == l2) {\n                    cnt++;\n                    p = 0;\n                }\n            }\n            count[i] = cnt;\n            next[i] = p;\n            for (int j = 0; j < i; j++) {\n                if (next[j] == p) {\n                    int prev_count = count[j];\n                    int pattern_count = (count[i] - count[j]) * ((n1 - j - 1) / (i - j));\n                    int remain_count = count[j + (n1 - j - 1) % (i - j)] - count[j];\n                    return (prev_count + pattern_count + remain_count) / n2;\n                }\n            }\n        }\n        return count[n1 - 1] / n2;\n    }\n}\n```\n
['C++', 'Java', 'Python3']