Codeforces Round #410 (Div. 2) A. Mike and palindrome
2 seconds
256 megabytes
standard input
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.
The first and single line contains string s (1 ≤ |s| ≤ 15).
Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.
- abccaa
- YES
- abbcca
- NO
- abcda
- 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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #410 (Div. 2)B. Mike and strings(暴力)
传送门 Description Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In ...
- 【推导】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 ...
- Codeforces Round #410 (Div. 2)
Codeforces Round #410 (Div. 2) A B略..A没判本来就是回文WA了一次gg C.Mike and gcd problem 题意:一个序列每次可以把\(a_i, a_{i ...
- set+线段树 Codeforces Round #305 (Div. 2) D. Mike and Feet
题目传送门 /* 题意:对于长度为x的子序列,每个序列存放为最小值,输出长度为x的子序列的最大值 set+线段树:线段树每个结点存放长度为rt的最大值,更新:先升序排序,逐个添加到set中 查找左右相 ...
- 数论/暴力 Codeforces Round #305 (Div. 2) C. Mike and Frog
题目传送门 /* 数论/暴力:找出第一次到a1,a2的次数,再找到完整周期p1,p2,然后以2*m为范围 t1,t2为各自起点开始“赛跑”,谁落后谁加一个周期,等到t1 == t2结束 详细解释:ht ...
- 暴力 Codeforces Round #305 (Div. 2) B. Mike and Fun
题目传送门 /* 暴力:每次更新该行的num[],然后暴力找出最优解就可以了:) */ #include <cstdio> #include <cstring> #includ ...
随机推荐
- SQL Server 2012安装配置(Part1 )
1 安装前准备 安装 SQL Server 2012 服务器及客户端前,需要提前做以下两项准备: SQL Server2012 依赖于.Net Framework 3.5.1 组件.Windows S ...
- 字符串转换JSON 的方法
function (sJSON) { if (window.JSON) { return window.JSON.parse(sJSON); } else { return eval('(' + sJ ...
- DaemonSet 典型应用场景【转】
Deployment 部署的副本 Pod 会分布在各个 Node 上,每个 Node 都可能运行好几个副本.DaemonSet 的不同之处在于:每个 Node 上最多只能运行一个副本. DaemonS ...
- Java中的集合Collection接口
/* 集合:集合是存储对象数据的集合容器.集合比数组的优势: 1. 集合可以存储任意类型的对象数据,数组只能存储同一种数据类型 的数据. 2. 集合的长度是会发生变化的,数组的长度是固定的.----- ...
- CodePlus #4 最短路
题目传送门 北极为什么会有企鹅啊,而且北纬91°在哪啊? 关键在建图 因为任意两个城市间都可以互相到达,再加上还有"快捷通道",光是建图就已经\(\rm{T}\)了-- 但这题给了 ...
- 01_9_Struts用ModelDriven接收参数
01_9_Struts用ModelDriven接收参数 1. 配置struts.xml文件 <package name="user" namespace="/use ...
- ios 设计模式总结
设计模式:备注:消息传递模型(Message Passing)是Objective-C语言的核心机制.在Objective-C中,没有方法调用这种说法,只有消息传递.在C++或Java中调用某个类的方 ...
- iview Tooltip换行及应用
第一种: <Tooltip placement="bottom"> <Button>Multiple lines</Button> <di ...
- 转 fine-tuning (微调)
https://blog.csdn.net/weixin_42137700/article/details/82107208
- java工作环境配置jdk,idea
下载 jdk 1.8 https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 配置环境 ...