Codeforces 题解 CF863A 【Quasi-palindrome】
此题本质上是:求一个数去掉后缀零后是否是回文串
因此,代码分为:
>>> 读入
>>> 删除后缀0
>>> 判断回文
>>> 转为数组存储
>>> 依次比较开头和结尾是否相同(头指针后移,尾指针前移)
>>> 输出结果
所以,我们有了:
#include <?????.?> //杜绝抄袭!
??? main() //杜绝抄袭!
{
int n;
//读入
scanf("%d", &n);
//删除后缀0
while (n % 10 == 0) n /= 10;
int a[10], len = 0; //a存储数组形式的n
bool huiwen = true; //删除后缀0的n是否是回文
//转为数组存储
while (n != 0) a[m++] = n % 10, n /= 10;
//依次比较开头和结尾是否相同(头指针后移,尾指针前移)
for (int i = 0, j = m - 1; i <= j; i++, j--)
if (a[i] != a[j]) huiwen = false;
//输出
if (huiwen)
printf("YES");
else
printf("NO");
return 0;
}
avoiding plagiarism! //杜绝抄袭!
Codeforces 题解 CF863A 【Quasi-palindrome】的更多相关文章
- Codeforces Gym 100570 E. Palindrome Query Manacher
E. Palindrome QueryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100570/pro ...
- Codeforces 798A - Mike and palindrome
A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- 每日一题:codeforces题解
题目 B. Peculiar Movie Preferences time limit per test 2 seconds memory limit per test 512 megabytes i ...
- Codeforces Round #300 Quasi Binary(DP)
Quasi Binary time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces 538 B. Quasi Binary
B. Quasi Binary time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- leetcode题解:Valid Palindrome(判断回文)
题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ig ...
- 【Codeforces 600C】Make Palindrome
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 计算出来每个字母出现的次数. 把字典序大的奇数出现次数的字母换成字典序小的奇数出现次数的字母贪心即可. 注意只有一个字母的情况 然后贪心地把字 ...
- NEKO's Maze Game - Codeforces 题解
题目 NEKO#ΦωΦ has just got a new maze game on her PC! The game's main puzzle is a maze, in the forms o ...
- Leetcode题解之Valid Palindrome II
1.题目描述 2.问题分析 使用两个下标,检测下标对应的字符是否相等,若不相等,则考察子串. 3.代码 bool validPalindrome(string s) { , j = s.size()- ...
随机推荐
- 本地存储localstorage
小小插件,封装了一个存取删 <script type="text/javascript"> /* *getItem(name) * *setItem(name,valu ...
- Python字符串类型判断错误
Python里面常用的字符串类型有str和unicode,如果要判断一个对象的类型,最好用basestring,否则可能会判断错误: str1 = "hello" str2 = u ...
- spring源码1
1.beans核心类 1.DefaultListableBeanFactory xmlBeanFactory xmlBeanFactory继承自DefaultListableBeanFactory,D ...
- LeetCode18. 四数之和
LeetCode18. 四数之和 给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个元素 a,b,c 和 d ,使得 a + b + c + d 的值 ...
- 通过C/C++,实现一元一次方程求解
通过C/C++,实现一元一次方程求解: #include <bits/stdc++.h> using namespace std; string str, str_l, str_r; st ...
- hdu 2647 Reward (topsort)
RewardTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- Centos内核参数优化
关于内核参数优化 net.ipv4.tcp_max_tw_buckets = 6000 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_ ...
- C#控制打印机通过不同纸盒/进纸口进纸打印
通常我们是通过程序操作打印机打印我们设置好的内容,但基本都是打印机默认进纸口打印:最近有一个通过C#程序控制两个进纸口分别进一张纸进行打印的需求,通过偿失找到了解决方案如下: 关于C#调用打印机打印的 ...
- SpringBoot学习(二)—— springboot快速整合spring security组件
Spring Security 简介 spring security的核心功能为认证(Authentication),授权(Authorization),即认证用户是否能访问该系统,和授权用户可以在系 ...
- 🔥《手把手教你》系列基础篇之3-python+ selenium-驱动浏览器和元素定位大法(详细)
1. 简介 上一篇中,只是简单地一带而过的说了一些驱动浏览器,这一篇继续说说驱动浏览器,然后再说一说元素定位的方法. 完成环境的安装并测试之后,我们对Selenium有了一定的了解了,接下来我们继续驱 ...