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
  1. abccaa
output
  1. YES
input
  1. abbcca
output
  1. NO
input
  1. abcda
output
  1. YES
    题意:必须修改一次字符串中的字符,问能不能成为回文串
    解法:模拟,注意必须要修改字符
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. const int maxn=;
  5. string s,ss,sss,ssss,s1;
  6. int main()
  7. {
  8. cin>>s;
  9. for(int i=;i<s.size();i++)
  10. {
  11. ss=s;
  12. for(int j=;j<;j++)
  13. {
  14. ss[i]='a'+j;
  15. if(s[i]==ss[i]) continue;
  16. sss=ss;
  17. ssss=ss;
  18. reverse(sss.begin(),sss.end());
  19. if(ssss==sss)
  20. {
  21. cout<<"YES";
  22. return ;
  23. }
  24.  
  25. }
  26. }
  27. cout<<"NO"<<endl;
  28. return ;
  29. }

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. Android Menu开源项目整合工程

    本实例整合了关于Android Menu的优秀开源代码,方便有需要用到Menu开源项目的小伙伴使用. 一.整合的项目有: SlidingMenu:https://github.com/jfeinste ...

  2. scala快速学习笔记(二):控制结构,类和对象

    IV.控制结构 1.if/else 除基本用法外,if/else语句能用来赋值,进而代替?:运算符.这得益于在Scala中,每个语句块都有值,就是该语句块最后一个语句的值.请看下面的代码. def a ...

  3. Educational Codeforces Round 9 E. Thief in a Shop NTT

    E. Thief in a Shop   A thief made his way to a shop. As usual he has his lucky knapsack with him. Th ...

  4. camus gobblin

    ####Camus is being phased out and replaced by Gobblin. For those using or interested in Camus, we su ...

  5. 【POJ3740】Easy Finding DLX(Dancing Links)精确覆盖问题

    题意:多组数据,每组数据给你几行数,要求选出当中几行.使得每一列都有且仅有一个1.询问是可不可行,或者说能不能找出来. 题解:1.暴搜.2.DLX(Dancing links). 本文写的是DLX. ...

  6. include <ctype.h> 头文件包含函数总结

    里面包含的函数主要是: 1.字符测试函数,函数原型一般为:int isXXXX( int ); 参数为int, 只能正确处理[0, 127]. 2.字符映射函数,函数原型一般为:int toXXXX( ...

  7. HDU4280 Island Transport —— 最大流 ISAP算法

    题目链接:https://vjudge.net/problem/HDU-4280 Island Transport Time Limit: 20000/10000 MS (Java/Others)   ...

  8. 织梦CMS被挂马特征汇总

    一.织梦CMS被挂马特征汇总 2013织梦CMS被挂马特征汇总.最近很多朋友反应后台多了几个系统管理员用户:service.spider等,而且自己之前的管理员用户登陆时候会提示用户名不存在.还有朋友 ...

  9. 星星dom

    <!DOCTYPE html><html><head><meta charset="UTF-8"><title>星星&l ...

  10. python二维数组初始化

    >>> a=[[0]*3 for i in range(3)]>>> a[[0, 0, 0], [0, 0, 0], [0, 0, 0]]>>> ...