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 ...
随机推荐
- Math.max.apply(null,arr)求最大值
1.首先了解一下call和apply call 和 apply 的第一个参数是null/undefined时函数内的this指向window 或global call/apply 用来改变函数的执行上 ...
- dll相关总结
1.动态链接库的使用有两种方式,一种是显式调用.一种是隐式调用. (1) 显式调用:使用LoadLibrary载入动态链接库.使用GetProcAddress获取某函数地址. (2) 隐式调用:可以使 ...
- (转)ThreadLocal-面试必问深度解析
ThreadLocal是什么 ThreadLocal是一个本地线程副本变量工具类.主要用于将私有线程和该线程存放的副本对象做一个映射,各个线程之间的变量互不干扰,在高并发场景下,可以实现无状态的调用, ...
- 《全栈性能Jmeter》-6JMeter元件详解
- element-ui的滚动条组件el-scrollbar(官方没有)
<template> <div style="height:600px;"> <el-scrollbar style="height:100 ...
- jenkins构建多个项目执行顺序设置
通常我们会在jenkins中构建多个项目,那么如果项目有依赖,或者有关联怎么办? 例: 如下图: ,有两个构建项目,posWeb是个web项目,welife是接口项目. 由于接口项目数据会影响pos ...
- python进阶(六) 虚拟环境git clone报错解决办法
在虚拟环境目录,进行git clone xxxxx.git 项目,报如下图错误 解决办法:env GIT_SSL_NO_VERIFY=true git clone xxxx.git
- XXE攻击学习
环境:lAMP simplexml_load_string.php代码内容 <?php $data = file_get_contents('php://input'); $xml = simp ...
- C语言记录汇总
uint32_t 转载自:http://blog.sina.com.cn/s/blog_6aea878e0100tl0f.html体会1>. 在写程序时注意"无符号类型&quo ...
- Css预处理器---Less(一)
一.简介: Less是一种动态样式语言,可以在样式中使用变量,继承,运算,函数 二.使用 (1)客户端使用 //引入您的.less样式文件,rel属性区别去css为stylesheet/less &l ...