题干:

Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome.

A palindrome is a string that reads the same backward as forward, for example strings "z", "aaa", "aba", "abccba" are palindromes, but strings "codeforces", "reality", "ab" are not.

Input

The first and single line contains string s (1 ≤ |s| ≤ 15).

Output

Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.

Examples

Input

abccaa

Output

YES

Input

abbcca

Output

NO

Input

abcda

Output

YES

题目大意:

麦克有一个只包含小写字母的字符串 s 。他想知道他能否恰好改变这个字符串的一个字母使得这个字符串成为回文串。

回文串是从前向后读与从后向前读相同的串,举个例子, "z", "aaa", "aba", "abccba" 都是回文串,但字符串 "codeforces", "reality", "ab" 就不是。

解题报告:

  分奇偶数讨论就行了,,注意是恰好改变一个字符,,也就是说不能不改。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e5 + 5;
char s[MAX];
int main()
{
	cin>>(s+1);
	int len = strlen(s+1);
	int cnt = 0;
	if(len&1) {
		for(int i = 1; i<=(len>>1); i++) {
			if(s[i] != s[len-i+1]) cnt++;
		}
		if(cnt <= 1) puts("YES");
		else puts("NO");
	}
	else {
		for(int i = 1; i<=(len>>1); i++) {
			if(s[i] != s[len-i+1]) cnt++;
		}
		if(cnt == 1) puts("YES");
		else puts("NO");
	}
	return 0 ;
 }

很早之前写的垃圾代码:(我当时也太水了吧)

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm> 
using namespace std;
char a[20];
char b[20];
int main()
{
	cin>>a;
	int len=strlen(a);
	int flag=0; 
	strcpy(b,a);
	reverse(b,b+len);
//	printf("%d\n",len);
	for(int i = 0; i<len; i++) {
		if(a[i]!=b[i]) {
			b[i]=a[i];
			a[len-1-i]=b[i];
			flag=1;
			break;
		}
	}
//	printf("%s\n%s",a,b);
	if(len&1) {
		for(int i = 0; i<len; i++) {
			if(a[i]!=b[i]) {
				printf("NO");
				return 0 ;
			}
		}
		printf("YES");
		return 0 ;	
	}
	else {
		if(flag==0) {
			printf("NO");
			return 0 ;
		}
		for(int i = 0; i<len; i++) {
			if(a[i]!=b[i]) {
				printf("NO");
				return 0 ;
			}
		}
		printf("YES");
		return 0 ;	
	} 
 }