zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    Many Equal Substrings CF
    Seek the Name, Seek the Fame POJ
    人人都是好朋友(离散化 + 并查集)
    建设道路
    day_30
    day_29作业
    day_29
    day_28
    day_27
    day_26作业
  • 原文地址:https://www.cnblogs.com/kimsimple/p/7463418.html
Copyright © 2011-2022 走看看