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 ...
随机推荐
- MacBook安装Win10
// 这是一篇导入进来的旧博客,可能有时效性问题. (一) 确认你的机型 以下机型支持: ü 安装64 位版本Win10 ü 不使用U盘安装Windows l MacBook(Retina 显 ...
- 在虚拟机中安装metasploit官方攻防模拟器
首先我们要在windwos下载安装perl环境.下载地址: http://pan.baidu.com/s/1i3GLKAp 然后我们安装 点击next 我同意,next next next,然后他会安 ...
- Unknown column in 'where clause'
Unknown column in 'where clause' 错误如题:Unknown column in 'XXX' 'where clause' 意思是:未知表名 排查 1,查表名是否有错 2 ...
- CSS中伪类选择器及伪元素
1.伪类选择器 在CSS中,最常用的伪类选择器是使用在a(锚)元素上的几种选择器,它们的使用方法如下: a:link{color:#FF0000;text-decoration:none} a:vis ...
- 学习SpirngMVC之如何获取请求参数
学习SpringMVC——如何获取请求参数 @RequestParam,你一定见过:@PathVariable,你肯定也知道:@QueryParam,你怎么会不晓得?!还有你熟悉的他(@Cooki ...
- Codeforces 833E Caramel Clouds
E. Caramel Clouds time limit per test:3 seconds memory limit per test:256 megabytes input:standard i ...
- Flexbox 练习和总结
练习地址: http://flexboxfroggy.com/ Welcome to Flexbox Froggy, a game where you help Froggy and friends ...
- Spark环境搭建(下)——Spark安装
1. 下载Spark 1.1 官网下载Spark http://spark.apache.org/downloads.html 打开上述链接,进入到下图,点击红框下载Spark-2.2.0-bin-h ...
- vue vue-style-loader !css-loader错误
最近在学习vue框架,使用webpack打包vue项目,在执行npm run start的时候 出现如下错误: This dependency was not found: * !!vue-style ...
- TypeScript笔记 6--接口
接口定义 接口和Java语言一样,都是通过关键字interface定义的,如下例子: interface People { name: string; age: number; hobby?: str ...