CF-798A
A. Mike and palindrometime limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard 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.
InputThe first and single line contains string s (1 ≤ |s| ≤ 15).
OutputPrint "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.
ExamplesinputabccaaoutputYESinputabbccaoutputNOinputabcdaoutputYES
题意:
能否恰好改变一个字符,使字符串变成一个回文串。
注意当有奇数个字符且本身为回文串时可以只改变中间的字符。
要满足动一次的条件
AC代码:
#include<bits/stdc++.h>
using namespace std; int main(){
string s;
int cnt=;
cin>>s;
for(int i=,j=s.size()-;i<j;i++,j--){
if(s[i]!=s[j]){
if(cnt==){
cout<<"NO"<<endl;
return ;
}
cnt=;
}
}
if(cnt==||s.size()%)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return ;
}
CF-798A的更多相关文章
- ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'
凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- cf Round 613
A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...
- ARC下OC对象和CF对象之间的桥接(bridge)
在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...
- [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现
1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...
- CF memsql Start[c]UP 2.0 A
CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...
- CF memsql Start[c]UP 2.0 B
CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...
- CF #376 (Div. 2) C. dfs
1.CF #376 (Div. 2) C. Socks dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...
- CF #375 (Div. 2) D. bfs
1.CF #375 (Div. 2) D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...
- CF #374 (Div. 2) D. 贪心,优先队列或set
1.CF #374 (Div. 2) D. Maxim and Array 2.总结:按绝对值最小贪心下去即可 3.题意:对n个数进行+x或-x的k次操作,要使操作之后的n个数乘积最小. (1)优 ...
随机推荐
- shell脚本分析mysql慢查询日志(slow log)
使用percona公司的pt-query-digest分析慢查询日志.分析.统计的结果的比較清晰 #!/bin/sh slowlog_path=/root/slow_query_log everysl ...
- Springmvc返回信息乱码解决
恩...基本上所有的配置信息都弄上了,但是还是乱码,最后在方法上面添加了下面的参数,就完美解决了: @RequestMapping(value="/action.action",m ...
- Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.
运行/usr/local/webserver/php/bin/phpize时出现: Configuring for: PHP Api Version: 20041225 Zend Module Api ...
- 手机pc显示不同的内容
<script type="text/javascript"> // var txt = $('#sjyincang').html(); // alert(txt); ...
- 03 http+socket编程批量发帖
<?php // http请求类的接口 interface Proto { // 连接url function conn($url); //发送get查询 function get(); // ...
- poj 1730Perfect Pth Powers(分解质因数)
id=1730">Perfect Pth Powers Time Li ...
- javascript正则表达式提取子匹配项
C#里所用的正则表达式,如果要提取字符串里的子匹配项(我都不知道那个叫啥名字,别名?)是很方便的,比如: Regex rx = new Regex(@"<title>(?< ...
- RTSP流媒体转发服务器源码
最新EasyDarwin已经支持海康.大华等标准RTSP/RTP协议的转发,代码及使用方法参看:用Darwin开发RTSP级联服务器(拉模式转发)http://blog.csdn.net/xiejia ...
- spring boot redis分布式锁 (转)
一. Redis 分布式锁的实现以及存在的问题 锁是针对某个资源,保证其访问的互斥性,在实际使用当中,这个资源一般是一个字符串.使用 Redis 实现锁,主要是将资源放到 Redis 当中,利用其原子 ...
- Java其实不支持垃圾回收
Java其实不支持垃圾回收.如果真的支持的话,大多数Java程序在运行的一开始就应该把程序本身删除,因为这些程序本身就是垃圾. // TODO: This is a 分割线. Please no ...