救救我吧,一片彩虹
查看原帖
救救我吧,一片彩虹
1420245
zymcandc楼主2025/6/30 09:11

一片彩虹,5AC 3WA 2TLE,救救我

#include <bits/stdc++.h>
using namespace std;
string str;
int fmid,smid,L,R;

int main()
{
    int i,j;
    cin>>str;
    int len = str.length();int temp = len;
    if(len % 2 == 0)
    {
        cout<<len;
        return 0;
    }
    str = "*"+str;
    bool flag = 1;
    while(1)
    {
        L = 1;R = temp;
        while(L<=R)
        {
            if(str[L] != str[R])
            {
                flag = false;
                break;
            }
            L++,R--;
        }
        if(!flag)    break;
        temp/=2;
    }
    cout<<temp;
    return 0;
}
2025/6/30 09:11
加载中...