Codeforces War of the Corporations

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<map>

#define sf scanf
#define pf printf

using namespace std;

typedef long long LL;

int main()
{
    ios_base::sync_with_stdio(0);
    string ms, sb;
    while(cin >> ms)
    {
        cin >> sb;

        LL mlen=ms.length() , sblen=sb.length(), i , cnt=0;

        for(i=0; i<mlen; i++)
        {
            if(ms.substr(i,sblen) == sb)
            {
                i+=(sblen-1);
                cnt++;
            }
        }

        cout << cnt << "\n";
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number