1 条题解
-
0
C++ :
#include <cstdio> #include <cstring> int isPalS(const char* s, int L){ for(int i=0, j=L-1; i<j; i++, j--) if(s[i] != s[j]) return 0; return 1; } int main(){ int N; if(scanf("%d", &N) != 1) return 0; static char s[32]; for(int i=0;i<N;i++){ if(scanf("%s", s) != 1) break; int L = (int)strlen(s); int h = (L + 1) / 2; /* 两半长度(奇数时共享中间位) */ int ok = isPalS(s, L) && isPalS(s, h) /* 前半 */ && isPalS(s + L - h, h); /* 后半 */ printf("%s\n", ok ? "Yes" : "No"); } return 0; }
- 1
信息
- ID
- 2714
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者