A. Quasi-palindrome
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string.

String t is called a palindrome, if it reads the same from left to right and from right to left.

For example, numbers 131 and 2010200 are quasi-palindromic, they can be transformed to strings "131" and "002010200", respectively, which are palindromes.

You are given some integer number x. Check if it's a quasi-palindromic number.

Input

The first line contains one integer number x (1 ≤ x ≤ 109). This number is given without any leading zeroes.

Output

Print "YES" if number x is quasi-palindromic. Otherwise, print "NO" (without quotes).

Examples
input
131
output
YES
input
320
output
NO
input
2010200
output
YES

这题代码题;
枚举每个中间点就行了;
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std; char s[],flag; int main(){
scanf("%s",s);
flag=-;
int len=strlen(s);
for(int i=len-;i>=;i--)
if(s[i]!=''){
flag=i;
break;
}
for(int i=;i<len;i++){
int x=;
while(i-x>=&&i+x<len&&s[i-x]==s[i+x]){
x++;
}
if(i+x>flag&&i-x<){
printf("YES");
return ;
}
}
for(int i=;i<len;i++){
int x=i,y=i+;
while(x>=&&y<len&&s[x]==s[y]){
x--; y++;
}
if(y>flag&&x<){
printf("YES");
return ;
}
}
printf("NO");
}

Codeforce A. Quasi-palindrome的更多相关文章

  1. codeforce 600C - Make Palindrome

    练习string 最小变换次数下,且字典序最小输出回文串. #include <cstdio> #include <cstring> #include <cmath> ...

  2. PALIN - The Next Palindrome 对称的数

    A positive integer is called a palindrome if its representation in the decimal system is the same wh ...

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

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

  4. [LeetCode] Palindrome Pairs 回文对

    Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that t ...

  5. [LeetCode] Palindrome Permutation II 回文全排列之二

    Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...

  6. [LeetCode] Palindrome Permutation 回文全排列

    Given a string, determine if a permutation of the string could form a palindrome. For example," ...

  7. [LeetCode] Palindrome Linked List 回文链表

    Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time ...

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

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

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

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

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

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

随机推荐

  1. Java反射-中级知识掌握

    PS:本文就Java反射常用的中级知识做下汇总和分析/cnxieyang@163.com/xieyang@e6yun.com

  2. 385cc412a70eb9c6578a82ac58fce14c 教大家破解md5验证值

    Md5密文破解(解密)可以说是网络攻击中的一个必不可少的环节,是工具中的一个重要"辅助工具".md5解密主要用于网络攻击,在对网站等进行入侵过程,有可能获得管理员或者其他用户的账号 ...

  3. 深入理解 react-router 路由系统

    作者:范洪春链接:https://zhuanlan.zhihu.com/p/20381597来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 在 web 应用开发中,路由 ...

  4. Pandas系列之入门篇——HDF5

    Pandas系列之入门篇--HDF5 简介 HDF5(层次性数据格式)作用于大数据存储,其高效的压缩方式节约了不少硬盘空间,同时也给查询效率带来了一定的影响, 压缩效率越高,查询效率越低.pandas ...

  5. hdu_4497GCD and LCM(合数分解)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4497 GCD and LCM Time Limit: 2000/1000 MS (Java/Other ...

  6. 关于win10系统安装VMware12Pro后,win10系统的 控制面板\网络和 Internet\网络连接\更改适配器选项卡中 没有虚拟网卡VMnet1和VMnet8图标,该如何把他们显示出来呢?

    安装VMware12Pro后,PC主机通过命令行:ipconfig/all ,查看发现没有VMnet1和VMnet8. 然后我首先尝试打开VMware12Pro的虚拟网络编辑器: 然后先点击" ...

  7. [学习OpenCV攻略][013][Mat - 基本图像容器]

    Mat 是一个类,由两个数据部分组成:矩阵头(包含矩阵尺寸,存储方法,存储地址等信息)和一个指向存储所有像素值的矩阵(根据所选存储方法的不同矩阵可以是不同的维数)的指针. 矩阵属于多个 Mat 对象, ...

  8. 数据结构与算法(c++)——反转链表

    算法概述:要求实现将一条单向链表反转并考虑时间复杂度. 算法分析: 数组法(略): 将列表元素逐个保存进数组,之后再逆向重建列表 点评:实现逻辑最简单,需要额外的内存开销. 移动指针: 通过三个指针逐 ...

  9. 利用H5构建地图和获取定位地点

    地图与地理定位 定位在大部分项目中都需要实现,如何实现主要有如下的几种方法 H5定位 在HTML5中navigator有很强大的功能,其中就有定位的方法 navigator.geolocation.g ...

  10. 邓_php_笔试!!!

    函数总结: ---------------------------------------------------------------------- 数组: 1.数组转换为字符串: implode ...