P2799国王的魔镜

it2026-03-10  7

链接

 

 

 

 

 想了好久(蒟蒻的不能蒟蒻)

题解:

#include<iostream>#include<cstdio>#include<cstring>#include<cmath>using namespace std;char c[100001];int m,n;bool b=1;void an(){ if(b==1) {if(m%2==1) {cout<<m;b=0;}//若长度为奇数,输出 if(m%2==0) { for(int i=0;i<m/2;i++) {if(b==1) {if(c[i]!=c[m-i-1]) //判断是否成回文 {cout<<m<<" ";b=0;}//否,输出 if(c[i]==c[m-i-1])//是,继续二分 {m=m/2; an(); } } } } } }

int main(){ gets(c); m=strlen(c); n=strlen(c); an();}

转载于:https://www.cnblogs.com/lcez56jsy/p/10403478.html

相关资源:数据结构—成绩单生成器
最新回复(0)