Codeforces 863A Quasi-palindrome
来源:互联网 发布:网络支付系统 编辑:程序博客网 时间:2024/06/02 04:17
题目链接:CF-863A
给定一个数x,如果在x前加任意多的前导0(可以没有),可以变成一个回文数,则输出YES,否则NO。
把数字末尾的0去掉然后在判断剩余数字是否是回文数即可。如101000,把末尾3个0去掉变成101,是回文数,输出YES。
#define _CRT_SECURE_NO_WARNINGS#include <iostream>#include <cstdio>#include <algorithm>using namespace std;int main() {int a[10];int x;scanf("%d", &x);int size = 0;for (int i = 1;i <= 10;++i){int mod = x % 10;a[size++] = mod;x /= 10;if (x == 0)break;}int cnt = 0;for (int i = 0;i < size;++i){if (a[i] != 0)break;if (a[i] == 0)cnt++;if (a[i + 1] != 0)break;}int re = size - cnt;bool flag = true;int s = 0;for (int i = cnt;i < size;++i){if (a[i] != a[size - 1 - s])flag = false;s++;}if (flag)printf("YES\n");elseprintf("NO\n");//system("pause");return 0;}
阅读全文
0 0
- Codeforces 863A Quasi-palindrome
- codeforces 863A Quasi-palindrome
- codeforces 863A 之 Quasi-palindrome
- codeforces 863A && Educational Codeforces Round 29 Quasi-palindrome
- CF 863A. Quasi-palindrome【water】
- A.Quasi-palindrome
- Quasi-palindrome
- codeforces B. Quasi Binary
- codeforces #300 B. Quasi Binary
- CodeForces 538B Quasi Binary
- Codeforces - 538B - Quasi Binary
- codeforces 798a Mike and palindrome 水题
- CodeForces 798A Mike and palindrome
- Codeforces 798A -Mike and palindrome
- codeforces 538 B.Quasi Binary(思维题)
- Codeforces Round #300 - Quasi Binary(贪心)
- Quasi Binary(Codeforces Round #300)
- !codeforces 538B-Quasi Binary-(思维)
- 第二周体验复杂度
- 1008. Elevator (20)
- 关于博客声明
- 20170922前端第四天
- 拖拽事件
- Codeforces 863A Quasi-palindrome
- poj 1308 入门(坑)
- 长链接 转短链接URL的设计思路
- 第二周汉诺塔问题
- 训练集---训练赛13
- C#上机作业及代码Question2
- 欧拉函数打表
- <Probabilistic Graphical Models>2 Graphical Models in Action
- pycharm以及numpy、matplotlib等安装