A. Mike and palindrome
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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
晚上要打第一场div2,先拿上一场的热热身,这个题就是改变一个字母使他变为回文串,不能改为相同字母哦,所以要改动字母为0的话只能改变中间的那个
#include <bits/stdc++.h>
using namespace std;
int main(){
int n=;
string s;
cin>>s;
int l=s.length();
for(int i=;i<l/;i++)
if(s[i]!=s[l--i])
n++;
if(n==||n==&&l%)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return ;
}

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

  1. 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 ...

  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) B. Mike and strings

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

  4. Codeforces Round #410 (Div. 2)B. Mike and strings(暴力)

    传送门 Description Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In ...

  5. 【推导】Codeforces Round #410 (Div. 2) C. Mike and gcd problem

    如果一开始就满足题意,不用变换. 否则,如果对一对ai,ai+1用此变换,设新的gcd为d,则有(ai - ai+1)mod d = 0,(ai + ai+1)mod d = 0 变化一下就是2 ai ...

  6. Codeforces Round #410 (Div. 2)

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

  7. set+线段树 Codeforces Round #305 (Div. 2) D. Mike and Feet

    题目传送门 /* 题意:对于长度为x的子序列,每个序列存放为最小值,输出长度为x的子序列的最大值 set+线段树:线段树每个结点存放长度为rt的最大值,更新:先升序排序,逐个添加到set中 查找左右相 ...

  8. 数论/暴力 Codeforces Round #305 (Div. 2) C. Mike and Frog

    题目传送门 /* 数论/暴力:找出第一次到a1,a2的次数,再找到完整周期p1,p2,然后以2*m为范围 t1,t2为各自起点开始“赛跑”,谁落后谁加一个周期,等到t1 == t2结束 详细解释:ht ...

  9. 暴力 Codeforces Round #305 (Div. 2) B. Mike and Fun

    题目传送门 /* 暴力:每次更新该行的num[],然后暴力找出最优解就可以了:) */ #include <cstdio> #include <cstring> #includ ...

随机推荐

  1. 假如m是奇数,且m>=3,证明m(m² -1)能被8整除

    m是奇数,且m>=3 =>m可以用表达式2n-1,n>=2 =>m²-1 = (2n-1)²-1 =>m²-1 = 4n²-4n+1-1 =>m²-1 = 4n²- ...

  2. LR脚本录制方式说明

    1.LR脚本录制方式说明1)HTML-based script基于HTML的脚本从内存中读取并下载资源,较少的关联处理,可以加入图片检查,回放时需要解析返回的信息a-基于用户行为的方式 web_lin ...

  3. 关系代数演算So Easy

    关系代数运算So Easy 关系代数是以关系为运算的一组高级运算的集合.由于定义为属性个数 相同的元组的集合,因此集合代数的操作就可以引入到关系代数中.关系代数也可以看做是一种抽象的查询语言,是对关系 ...

  4. Linux 备份

    备份之前的准备工作 安装常用的软件 常用软件的安装,见我另一篇blog Ubuntu 16.04 安装札记 的第四部分. 清理系统中没用的垃圾 至于垃圾清理,主要清理对象有 sudo rm -r ~/ ...

  5. oracle 数据导到 sql server

    方法一: navicate:用法比较简单,选择工具-数据传输就可以了.目前测试了下暂时没遇到什么问题. 方法二: Microsoft SQL Server Migration Assistant 8. ...

  6. 在ubuntu中用命令安装iperf

    Iperf的安装要换成阿里的源 sudo add-apt-repository "ppa:patrickdk/general-lucid" sudo apt-get update ...

  7. 01_7_cookies

    01_7_cookies 1. cookies 1.1服务器可以向客户端写内容 1.2只能是文本内容 1.3客户端可以阻止服务器写入 1.4只能拿到自己webapp写入的东西 1.5Cookie分为两 ...

  8. 音频框架TheAmazingAudioEngine实现音效

    TheAmazingAudioEngine是Michael Tyson开源的iOS第三方音频框架.很多音频类APP应用这个框架作开发. 应用这个框架,可以比较方便地实现iOS音频开发中的各种音效的实现 ...

  9. iOS应用架构谈-part1概述

    当我们讨论客户端应用架构的时候,我们在讨论什么? 其实市面上大部分应用不外乎就是颠过来倒过去地做以下这些事情: --------------- --------------- ------------ ...

  10. 将远程分支拷贝到本地,并更新代码push到原分支

    第一步:git clone +主分支 第二步:git fetch origin 分支名 第三步:git checkout -b 分支名 origin/分支名 第四步:git pull origin 分 ...