JustOj 1927: 回文串
题目描述
回文串是从左到右或者从右到左读起来都一样的字符串,试编程判别一个字符串是否为回文串。
输入
输入一个字符串。串长度<255.
输出
判别输入的字符串是否为回文串,是输出"Y",否则输出"N"。
样例输入
abcba
样例输出
Y 题解:判断首尾是否一样即可
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
return x>y;
}
const int N=;
const int mod=1e9+;
char a[];
int main()
{
std::ios::sync_with_stdio(false);
scanf("%s",&a);
int len=strlen(a);
int flag=;
for(int i=;i<=len/;i++){
if(a[i]!=a[len-i-]){
flag=;
break;
}
}
if(flag) cout<<"Y"<<endl;
else cout<<"N"<<endl;
return ;
}
JustOj 1927: 回文串的更多相关文章
- [LeetCode] Longest Palindrome 最长回文串
Given a string which consists of lowercase or uppercase letters, find the length of the longest pali ...
- [LeetCode] Shortest Palindrome 最短回文串
Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. ...
- [LeetCode] Palindrome Partitioning II 拆分回文串之二
Given a string s, partition s such that every substring of the partition is a palindrome. Return the ...
- [LeetCode] Palindrome Partitioning 拆分回文串
Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...
- [LeetCode] Longest Palindromic Substring 最长回文串
Given a string S, find the longest palindromic substring in S. You may assume that the maximum lengt ...
- bzoj 3676 回文串 manachar+hash
考虑每个回文串,它一定是它中心字母的最长回文串两侧去掉同样数量的字符后的一个子串. 所以我们可以用manachar求出每一位的回文半径,放到哈希表里并标记出它的下一个子串. 最后拓扑排序递推就行了.. ...
- BZOJ 3676: [Apio2014]回文串
3676: [Apio2014]回文串 Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 2013 Solved: 863[Submit][Status ...
- SPOJ - PLSQUARE Palin Squar(hash+回文串)
题意:给你一个n*n (n<=200)的字符串矩阵,问你每行每列都是回文串的最大的m*m的矩阵是多少 题解:首先答案不满足单调性,即m成立而m-1与m+1都却不一定成立,所以必须枚举答案确定现在 ...
- 删除部分字符使其变成回文串问题——最长公共子序列(LCS)问题
先要搞明白:最长公共子串和最长公共子序列的区别. 最长公共子串(Longest Common Substirng):连续 最长公共子序列(Longest Common Subsequence,L ...
随机推荐
- 记录关于vs2008 和vs2015 的报错问题
出现了 VS2008无法创建项目,无法打开项目的情况,提示这个注册表键值有问题 HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ MSBuild \ ToolsV ...
- LigerUi遮罩的两个方法
$.ligerDialog.waitting('正在查询,请稍候...'); $.ligerDialog.close();
- VueI18n的应用
.npm install vue-i18n .在 main.js 中引入 vue-i18n import VueI18n from 'vue-i18n' Vue.use(VueI18n) .在main ...
- ArcGIS工具备忘
1.Repair Geometry (Data Management) 几何图形修复,比如面图层不满足节点坐标逆时针 2.Raster Domain (3D Analyst) 获取栅格范围 3.Int ...
- [py]super调用父类的方法---面向对象
super()用于调用父类方法 http://www.runoob.com/python/python-func-super.html super() 函数是用于调用父类(超类)的一个方法. clas ...
- MySQL Split 函数
本文地址:http://www.cnblogs.com/qiaoyihang/p/6270165.html mysql 本身并没有 split 函数,但是,我们实现累死功能的自定义函数是非常简单的 创 ...
- Android 7.0下,拍摄照片报错
对于面向 Android 7.0 的应用,Android 框架执行的 StrictMode API 政策禁止在您的应用外部公开 file:// URI.如果一项包含文件 URI 的 intent 离开 ...
- (转)Thread中yield方法
先上一段代码 public class YieldExcemple { public static void main(String[] args) { Thread threada = new Th ...
- 【Java】-NO.16.EBook.4.Java.1.001-【疯狂Java讲义第3版 李刚】- UML
1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.001-[疯狂Java讲义第3版 李刚]- Style:EBook Series:Java Since ...
- unicode gbk utf-8的差异
GB2312(1980年)定义,包含6763个汉字,682个字符 GBK1.0 定义了21003个汉字,21886个字符 ASCII->GB2312->GBK 编码方式向后兼容,即同一个字 ...