Codeforce A. Quasi-palindrome
1 second
256 megabytes
standard input
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.
The first line contains one integer number x (1 ≤ x ≤ 109). This number is given without any leading zeroes.
Print "YES" if number x is quasi-palindromic. Otherwise, print "NO" (without quotes).
131
YES
320
NO
2010200
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的更多相关文章
- codeforce 600C - Make Palindrome
练习string 最小变换次数下,且字典序最小输出回文串. #include <cstdio> #include <cstring> #include <cmath> ...
- PALIN - The Next Palindrome 对称的数
A positive integer is called a palindrome if its representation in the decimal system is the same wh ...
- [LeetCode] Longest Palindrome 最长回文串
Given a string which consists of lowercase or uppercase letters, find the length of the longest pali ...
- [LeetCode] Palindrome Pairs 回文对
Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that t ...
- [LeetCode] Palindrome Permutation II 回文全排列之二
Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...
- [LeetCode] Palindrome Permutation 回文全排列
Given a string, determine if a permutation of the string could form a palindrome. For example," ...
- [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 ...
- [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 ...
随机推荐
- 推荐几个不错的 java 教程和 HTML 教程
Java入门第一季 Java入门第二季 2小时学会Spring Boot Java模板引擎之Freemarker HTML+CSS基础课程 H5+JS+CSS3实现七夕言情 jQuery基础系列
- python对pywifi模块的认识
pywifi是一个用来搞wifi的模块 下一章我们将用他破解wifi密码 pywifi安装 pip install pywifi 下列代码判断是否有无限网卡 import pywifi import ...
- NullPointerException org.apache.commons.digester.Digester.getXMLReader(Digester.java:1058)
http://pwu-developer.blogspot.com/2010/01/nullpointerexception.html Maven is great build tool making ...
- .25-浅析webpack源码之事件流compilation(3)
这一节跑下一批plugin. compiler.apply( new EnsureChunkConditionsPlugin(), new RemoveParentModulesPlugin(), n ...
- redis常见命令使用
这篇经验主要介绍了Redis常见用的一些操作命令.这篇例子是在windows上操作的.linux类似.写的一些基础,大神就别看了. 工具/原料 redis windows 方法/步骤 1 可以 ...
- 关于JWPlayer播放器的一些测试学习
<!DOCTYPE html><html><head> <title>jwplayer播放器测试</title> <script ty ...
- ip 淘宝ip库 精简版
<?php header('Content-type: text/html; charset=utf-8'); //根据ip获取城市.网络运营商等信息 function findCityByIp ...
- UWP: 实现 UWP 应用自启动
在上一篇文章中,我们实现了使用命令行来启动 UWP 应用,在这一篇文章中,我们会实现 UWP 应用自启用的实现,也即开机后或用户登陆后,应用自己启动.这些特性原来都是 Win32 程序所具备的,UWP ...
- 一次__libc_message的排查
信号是6,abort调用的.总体而言,当你malloc的指针为A,但是你free的指针不是A,则容易出这个错,当然假设你free的刚好是别人malloc的,则还是正常. 还有一种是你free的地址在 ...
- 2017-06-26(groupadd groupmod groupdel)
groupadd groupadd 组名 (创建用户组) groupadd -g 组编号 组名 (创建组名 并且指定编号) groupmod groupmod -n 新组名 旧组名 ...