51Nod 1347 旋转字符串 | 规律

 

 

 

Input示例
aa
ab
Output示例
YES
NO

 规律:abcabc

只需判断原始字符串

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i,a,n) for(int i = a; i < n; i++)
#define repe(i,a,n) for(int i = a; i <= n; i++)
#define per(i,n,a) for(int i = n; i >= a; i--)
#define clc(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f3f
#define N 1000010
char str[N];
map<char,int> mm;
int main()
{
    //freopen("in.txt","r",stdin);

    LL n;
    while(~scanf("%s",str)){
        int len=strlen(str);
        if(len%2!=0){
            puts("NO");
            continue;
        }
        int mid=len/2;
        bool f=0;
        for(int i=0;i<mid;i++){
            if(str[i]!=str[mid+i]){
                f=1;
                break;
            }
        }
        if(f)
        {
            puts("NO");
            continue;
        }else
        {
            puts("YES");
        }
    }
    return 0;
}

 

posted @ 2017-09-01 15:25  kimsimple  阅读(244)  评论(0编辑  收藏  举报