A题。。暴力枚举在每个位置添加字符,然后检查一下是不是回文串
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 #include <cmath> 6 #include <vector> 7 8 using namespace std; 9 10 #define LL long long 11 #define eps 1e-8 12 #define inf 0x3f3f3f3f 13 #define lson l, m, rt << 1 14 #define rson m+1, r, rt << 1 | 1 15 #define mnx 31000 16 17 char s[20], ch[20]; 18 bool check(){ 19 int n = strlen( ch ); 20 for( int i = 0, j = n-1; i <= j; ++i, --j ){ 21 if( ch[i] != ch[j] ) return false; 22 } 23 return true; 24 } 25 int main(){ 26 scanf( "%s", &s ); 27 int n = strlen( s ); 28 for( int i = 0; i <= n; ++i ){ 29 for( int j = 'a'; j <= 'z'; ++j ){ 30 for( int k = 0, m = 0; k <= n; ++k ){ 31 if( i == k ) 32 ch[k] = (char)j; 33 else 34 ch[k] = s[m++]; 35 } 36 ch[n+1] = '