Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <set>
- #include <string>
- #include <algorithm>
- using namespace std;
- void cv(vector <int> v){
- for (auto x: v) cout<<x<<' ';
- cout<<'\n';
- }
- int N;
- string S,T;
- int main()
- {
- /*ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);*/
- cin>>T>>S>>N;
- int ans=0;
- string st="";
- for (int i=0;i<N;++i){
- //cout<<i<<' '<<st<<'\n';
- st+=S;
- }
- /*cout<<"st= "<<st<<"\n";
- cout<<"st.size() = "<<st.size()<<'\n';
- cout<<"T.size() = "<<T.size()<<'\n';
- cout<<"st.size() - T.size() = "<<st.size() - T.size()<<'\n';*/
- if (T.size() > st.size()){
- cout<<0<<'\n';
- exit(0);
- }
- string x = st.substr(st.size() - T.size(), T.size());
- if (x == T){
- //cout<<"+\n";
- ans++;
- }
- //cout<<"x= "<<x<<'\n';
- for (int i = st.size() - T.size()-1; i >=0 ;--i){
- //cout<<"i= "<<i<<'\n';
- if (x.size()>0) x.pop_back();
- x = st[i] + x;
- //cout<<"x= "<<x<<'\n';
- if (x == T){
- //cout<<"+\n";
- ans++;
- }
- }
- cout<<ans<<"\n";
- }
- /*
- ABAAAAAABBBBBBABABABABABABABAABABA
- ABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABABABABABABABABABBABABBABABBAAAAAAAAAAAAAAAAABBBBBBBBBABABABABABABABABBABABABABABABABABABABABAANANANNABBABAB
- 100000
- LALALA
- LALA
- 3
- AAAAA
- A
- 4
- MON
- AMONGUS
- 3
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement