跳到正文

闲话

code

myuncloud约 1 分钟
原文

这是 2026年11月9日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2026年11月9日
收录
2026年11月9日
更新
2026年11月21日
篇幅
约 1 分钟

版本

  1. v2当前
  2. v1
C++
#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-9;

bool check(const string &s, int l, int r);

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		string s;
		cin >> s;
		if(s.size()<4){
			cout << "No\n";
			continue;
		}
		bool out=false;
		for (int j = 1; j < s.size() - 2; j++) {
			if(check(s, 0, j) && check(s, j+1, s.size()-1)){
				out=true;
				break;
			}
		}
		cout << (out ? "Yes\n" : "No\n");
	}
	return 0;
}

bool check(const string &s, int l, int r){
	int mid=(l+r)>>1;
	for(int i=l ; i<=mid ; i++){
		if(s[i]!=s[r-i+l]) return false;
	}
	return true;
}