题目描述

回文串是从左到右或者从右到左读起来都一样的字符串,试编程判别一个字符串是否为回文串。

输入

输入一个字符串。串长度<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: 回文串的更多相关文章

  1. [LeetCode] Longest Palindrome 最长回文串

    Given a string which consists of lowercase or uppercase letters, find the length of the longest pali ...

  2. [LeetCode] Shortest Palindrome 最短回文串

    Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. ...

  3. [LeetCode] Palindrome Partitioning II 拆分回文串之二

    Given a string s, partition s such that every substring of the partition is a palindrome. Return the ...

  4. [LeetCode] Palindrome Partitioning 拆分回文串

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...

  5. [LeetCode] Longest Palindromic Substring 最长回文串

    Given a string S, find the longest palindromic substring in S. You may assume that the maximum lengt ...

  6. bzoj 3676 回文串 manachar+hash

    考虑每个回文串,它一定是它中心字母的最长回文串两侧去掉同样数量的字符后的一个子串. 所以我们可以用manachar求出每一位的回文半径,放到哈希表里并标记出它的下一个子串. 最后拓扑排序递推就行了.. ...

  7. BZOJ 3676: [Apio2014]回文串

    3676: [Apio2014]回文串 Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 2013  Solved: 863[Submit][Status ...

  8. SPOJ - PLSQUARE Palin Squar(hash+回文串)

    题意:给你一个n*n (n<=200)的字符串矩阵,问你每行每列都是回文串的最大的m*m的矩阵是多少 题解:首先答案不满足单调性,即m成立而m-1与m+1都却不一定成立,所以必须枚举答案确定现在 ...

  9. 删除部分字符使其变成回文串问题——最长公共子序列(LCS)问题

    先要搞明白:最长公共子串和最长公共子序列的区别.    最长公共子串(Longest Common Substirng):连续 最长公共子序列(Longest Common Subsequence,L ...

随机推荐

  1. Git/GitHub基本操作

    GitGit是分布式版本控制工具,SVN是集中式版本控制,有单点故障的问题GitHub是Git的代码托管中心,类似的国内有码云,是远程维护库Git的优势大部分操作在本地完成,不需要联网完整性有保证尽可 ...

  2. uWSGI+APScheduler不能执行定时任务

    在本地项目中使用APScheduler运行定时任务ok,但是在服务器上用uwsgi部署的Django环境下,APScheduler定时任务并不会被启动. 原因:uwsgi 默认one thread o ...

  3. C 语言循环结构

      25.有如下程序 main() { int i,sum; for(i=1;i<=3;sum++) sum+=i; printf("%d\n",sum); } 该程序的执行 ...

  4. Spark:java.net.BindException: Address already in use: Service 'SparkUI' failed after 16 retries!

    Spark多任务提交运行时候报错. java.net.BindException: Address already retries! at sun.nio.ch.Net.bind0(Native Me ...

  5. 微信小程序中this使用

    微信小程序中,在wx.request({});方法调用成功或者失败之后,有时候会需要获取页面初始化数据data的情况,这个时候,如果使用,this.data来获取,会出现获取不到的情况,调试页面也会报 ...

  6. 遇到CloudFlare邮箱混淆,如何解密?

    <script type="text/javascript">$(function() { $(".__cf_email__").each(func ...

  7. Kibana5.x界面简要介绍(含x-pack插件)

    简介:Kibana是一个为 ElasticSearch 提供的数据分析的 Web 接口(5601).可使用它对日志进行高效的搜索.可视化.分析等各种操作.Kibana目前最新的版本5.3.X-Pack ...

  8. C#使用HttpWebRequest与HttpWebResponse模拟用户登录

    模拟艺龙旅游网登录 想模拟登录,首先整理一下流程 1.通过360浏览器(IE,火狐等等)F12开发人员工具抓到相关数据 2.获取验证码(拿到cookie),登录时也需要使用 3.登录 -------- ...

  9. css3d旋转

    一.包裹层添加 -webkit-perspective: 800px; -moz-perspective: 800px; 使子元素获得3D效果支持   二.自持子元素需支持3D效果 -webkit-t ...

  10. 003-SqlHelper.cs/Web.config

    <?xml version="1.0" encoding="utf-8"?> <!-- 有关如何配置 ASP.NET 应用程序的详细信息,请访 ...