Description

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
题意:必须修改一次字符串中的字符,问能不能成为回文串
解法:模拟,注意必须要修改字符
 #include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=;
string s,ss,sss,ssss,s1;
int main()
{
cin>>s;
for(int i=;i<s.size();i++)
{
ss=s;
for(int j=;j<;j++)
{
ss[i]='a'+j;
if(s[i]==ss[i]) continue;
sss=ss;
ssss=ss;
reverse(sss.begin(),sss.end());
if(ssss==sss)
{
cout<<"YES";
return ;
} }
}
cout<<"NO"<<endl;
return ;
}

Codeforces Round #410 (Div. 2) A的更多相关文章

  1. Codeforces Round #410 (Div. 2)

    Codeforces Round #410 (Div. 2) A B略..A没判本来就是回文WA了一次gg C.Mike and gcd problem 题意:一个序列每次可以把\(a_i, a_{i ...

  2. Codeforces Round #410 (Div. 2)C. Mike and gcd problem

    题目连接:http://codeforces.com/contest/798/problem/C C. Mike and gcd problem time limit per test 2 secon ...

  3. Codeforces Round #410 (Div. 2)(A,字符串,水坑,B,暴力枚举,C,思维题,D,区间贪心)

    A. Mike and palindrome time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...

  4. Codeforces Round #410 (Div. 2)A B C D 暴力 暴力 思路 姿势/随机

    A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  5. Codeforces Round #410 (Div. 2) A. Mike and palindrome

    A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  6. Codeforces Round #410 (Div. 2) A. Mike and palindrome【判断能否只修改一个字符使其变成回文串】

    A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  7. Codeforces Round #410 (Div. 2)D题

    D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  8. Codeforces Round #410 (Div. 2)C题

    C. Mike and gcd problem time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  9. Codeforces Round #410 (Div. 2) B

    B. Mike and strings time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. ubuntu编译airplay

    1.alsa/asoundlib.h: No such file or directory 缺少一个库: apt-get install libasound2-dev   2.fatal error: ...

  2. Tomcat配置,Myeclipse破解和各种设置

    转自:http://www.cnblogs.com/tyjsjl/archive/2006/11/14/2156111.html 根据tomcat来配置eclipse和MyEclipse结合使用起来, ...

  3. 设计模式学习笔记——Observer观察者模式

    观察者模式里面有两个东西:观察者(Observer)和目标(Subject).当目标发生变化的时候,观察者随之起舞,也作出相应的变化.此为观察者模式. 这是怎么做到的?主要是目标里面存有一份观察者的名 ...

  4. 责任链模式-Chain of Responsibility

    责任链模式:使多个对象都有机会处理请求,从而避免请求的发送者和接收者之间的耦合关系.将这个对象连成一条链,并沿着这条链传递该请求,直到有一个对象处理它为止. 责任链模式结构图: 代码实现: 责任链模式 ...

  5. Ural 1635 Mnemonics and Palindromes(DP)

    题目地址:space=1&num=1635">Ural 1635 又是输出路径的DP...连着做了好多个了. . 状态转移还是挺简单的.要先预处理出来全部的回文串,tag[i] ...

  6. window10 java 环境变量配置

    JAVA_HOME (可有可无) CLASSPATH  :   C:\Program Files\Java\jdk1.8.0_91\lib\dt.jar;C:\Program Files\Java\j ...

  7. navcat for mysql 连接远程数据库 教程

    1.首先进入数据库: mysql -uroot -p 2.然后打开数据库设置远程连接权限: mysql>GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'ID ...

  8. mysql优化----explain的列分析

    sql语句优化: : sql语句的时间花在哪儿? 答: 等待时间 , 执行时间. 等待时间:看是不是被锁住了,那就不是语句层面了是服务端层面了,看连接数内存. 执行时间:到底取出多少行,一次性取出1万 ...

  9. BestCoder5 1001 Poor Hanamichi(hdu 4956) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4956(它放在题库后面的格式有一点点问题啦,所以就把它粘下来,方便读者观看) 题目意思:给出一个范围 [ ...

  10. html5--6-50 动画效果-变形

    html5--6-50 动画效果-变形 实例 学习要点 掌握2D变形动画 了解3D变形动画 transform:2D变形: 通过 CSS3 转换,我们能够对元素进行移动.缩放.转动.拉长或拉伸.转换方 ...