Codeforces Round #410 (Div. 2)-A. Mike and palindrome-思维
来源:互联网 发布:认识奢侈品的软件 编辑:程序博客网 时间:2024/06/06 00:58
。。一道题都不会写,不知道这样下去还有什么意思。。
给你个串,如果这个串可以改动一个字符就变成回文串
那么就输出yes。
没有考虑如果本身也是回文串但是是奇数长度,改变中间那个也行。。
#include <bits/stdc++.h>using namespace std;int main(){ char a[20]; cin>>a; int len=strlen(a); if(len==1) { printf("YES\n"); return 0; } int j=len-1; int sum=0; int sum1=0; int x=0; bool flag=false; if(len%2==0) x=len/2-1; else {x=len/2; flag=true; } for(int i=0;i<=x;i++) { if(a[i]!=a[j]) { //cout<<a[i]<<a[j]<<endl; sum++;} j--; } //cout<<sum<<endl; if(sum==1||(sum==0&&flag)) printf("YES\n"); else printf("NO\n"); return 0;}
0 0
- Codeforces Round #410 (Div. 2)-A. Mike and palindrome-思维
- Codeforces Round #410 (Div.2) A.Mike and palindrome-模拟
- Codeforces Round #410 (Div. 2) Mike and gcd problem 思维
- Codeforces Round #410 (Div. 2) Mike and distribution 思维
- Codeforces Round #410 (Div. 2) D. Mike and distribution 思维
- Codeforces Round #305 (Div. 2) A. Mike and Fax
- Codeforces Round #305 (Div. 2), problem: (A) Mike and Fax
- Codeforces Round #305 (Div. 2)--A. Mike and Fax
- Codeforces Round #305 (Div. 2)A. Mike and Fax
- Codeforces Round #361 (Div. 2) A. Mike and Cellphone
- Codeforces Round #361 (Div. 2) A. Mike and Cellphone
- Codeforces Round #361 (Div. 2) A. Mike and Cellphone
- Codeforces Round #361 (Div. 2)A. Mike and Cellphone
- Codeforces Round #361 (Div. 2) A. Mike and Cellphone ( 模拟 )
- Codeforces Round #361 (Div.2) - A. Mike and Cellphone
- Codeforces Round #361 (Div. 2) 689A Mike and Cellphone
- CF-Codeforces Round #410 (Div. 2)-D-Mike and distribution
- Codeforces Round #410 (Div. 2) D. Mike and distribution(贪心)
- 日常。。。续
- 商品展示
- DOM Node类
- LeetCode#237. Delete Node in a Linked List
- Collaborative Filtering 协同过滤小结 part-3:SVD的应用及变种
- Codeforces Round #410 (Div. 2)-A. Mike and palindrome-思维
- 177.把排序数组转换为高度最小的二叉搜索树
- python3.6中MySQL表的创建和删除
- 日常。。。又续
- 虚拟机使用
- 快速搭建一个简单的T-MVP项目
- 运算符&与&&,|与||的区别
- Java迭代器:iterator和iterable接口的区别
- CODE[VS] 1033 蚯蚓的游戏问题(最大费用最大流?)