548A Codeforces - Mike and Fax


548A Codeforces - Mike and Fax




Solution in C++

#include <bits/stdc++.h>

using namespace std;

string inp;
int len,sz;

int main()
{
    cin>>inp>>len;
    sz=inp.size();
    if(len>sz || sz%len)return cout<<"NO" ,0;
    len=sz/len;
    for(int i=0;i<sz;i+=len)
    {
        string test=inp.substr(i,len);
        for(int o=0;o<(len/2);o++)
        {
            if(test[o]!=test[len-o-1])return cout<<"NO" ,0;
        }
    }
    cout<<"YES";
    return 0;
}

Share on Google Plus

About Mohamed Sobhi

My name is Mo.Sobhy ,I study at School excelling high school in Ain Shams ,Cairo
My hobbies is programming ,and web development ,playing chess and writing horror stories.
    Blogger Comment
    Facebook Comment

0 التعليقات:

إرسال تعليق