Palindrome Numbers UVA - 12050(第几个回文数)
长度为k的回文串个数有9*10^(k-1)
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff;
int num[maxn], a[maxn];
void init()
{
num[] = num[] = ;
for(int i=; i<; i+=)
num[i] = num[i+] = num[i-] * ;
} int main()
{
init();
LL n;
while(cin>> n && n)
{
mem(a, );
int len = ;
while(n - num[len] > )
{
n -= num[len];
len++;
}
n--;
for(int i=len/+; i<=len; i++)
{
a[i] = n%;
n /= ;
}
a[len]++;
for(int i=; i<=len/; i++)
a[i] = a[len-i+];
for(int i=; i<=len; i++)
printf("%d", a[i]);
printf("\n"); }
return ;
}
Palindrome Numbers UVA - 12050(第几个回文数)的更多相关文章
- 009 Palindrome Number 判断一个正整数是否是回文数
详见:https://leetcode.com/problems/palindrome-number/description/ 实现语言:Java 方法一: class Solution { publ ...
- [2014亚马逊amazon] 在线笔试题 大于非负整数N的第一个回文数 Symmetric Number
1.题目 如标题,求大于整数N(N>=0)的第一个回文数的字符串表示形式. 这个题目也是当时笔试第一次见到,花了一个小时才做出了.慢慢总结还是挺简单的. 2.分析 分析如下: (1)一位数N(9 ...
- POJ2402 Palindrome Numbers 回文数
题目链接: http://poj.org/problem?id=2402 题目大意就是让你找到第n个回文数是什么. 第一个思路当然是一个一个地构造回文数直到找到第n个回文数为止(也许大部分人一开始都是 ...
- POJ2402 Palindrome Numbers第K个回文数——找规律
问题 给一个数k,给出第k个回文数 链接 题解 打表找规律,详见https://www.cnblogs.com/lfri/p/10459982.html,差别仅在于这里从1数起. AC代码 #inc ...
- POJ 2402 Palindrome Numbers(LA 2889) 回文数
POJ:http://poj.org/problem?id=2402 LA:https://icpcarchive.ecs.baylor.edu/index.php?option=com_online ...
- leetcode 9 Palindrome Number 回文数
Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. S ...
- [Swift]LeetCode479. 最大回文数乘积 | Largest Palindrome Product
Find the largest palindrome made from the product of two n-digit numbers. Since the result could be ...
- leetcode-479-Largest Palindrome Product(找到两个乘数相乘得到的最大的回文数)
题目描述: Find the largest palindrome made from the product of two n-digit numbers. Since the result cou ...
- 有趣的数-回文数(Palindrome number)
文章转自http://blog.163.com/hljmdjlln@126/blog/static/5473620620120412525181/ 做LC上的题"Palindrome num ...
随机推荐
- 异常处理简单例子--python
捕获所有异常 #!/usr/bin/pythona = 10b = 0try: c = a/b print c print 'nothing happen...'#todo: catch all ex ...
- C51中的关键字和ANSIC标准关键字
C51中的关键字和ANSIC标准关键字 作 者:武力戡乱 修改日期:2017-09-05 备 注: 1.总备注信息 2.联系方式 3.其它博文链接:武力戡乱博客目录总表 内 ...
- Delphi 10.3 Rio + iOS 12.1 SDK 编译错误 "libcharset.1.dylib"
环境版本: Delphi 10.3 Rio iOS 12.1 SDK Xcode 10.1 (10B61) 错误讯息:[DCC Error] E2597 ld: file not found: /us ...
- Android开发——RecyclerView特性以及基本使用方法(二)
0. 前言 随着Android的发展,虽然ListView依旧重要,但RecyclerView确实越来越多的被大家使用.但显然并不能说RecyclerView就一定优于ListView,而是应该根据 ...
- 带Alpha通道的色彩叠加问题
css3的rgba色彩模式.png/gif图片的alpha通道.canvas的rgba色彩模式.css3的阴影.css3的opacity属性等等,这些应用在网页中,有意无意间,我们的页面多了许多半透明 ...
- 代理神器allproxy
背景 allproxy意为all as proxy,即是说所有设备均可以成为一个网络代理,唯一的要求就是有网络访问权限. 一般的代理软件要求宿主机必须有公网地址,然后才能把网络代理出去,但在实际情况下 ...
- 利用HOG+SVM实现行人检测
利用HOG+SVM实现行人检测 很久以前做的行人检测,现在稍加温习,上传记录一下. 首先解析视频,提取视频的每一帧形成图片存到磁盘.代码如下 import os import cv2 videos_s ...
- Daily Scrum 12.22
姓名 上周末任务 今日任务 刘垚鹏 完善和增加quiz页面的过滤功能 完善和增加quiz页面的过滤功能 王骜 对问答功能的修复 对问答功能的修复 林旭鹏 存储文件路径太长导致bug修复 存储文件路径太 ...
- one team
Double H Team 1.队员 王熙航211606379(队长) 李冠锐211606364 曾磊鑫211606350 戴俊涵211606359 聂寒冰211606324 杨艺勇211606342 ...
- Linux内核分析作业 NO.4
扒开系统调用的三层皮(上) 于佳心 原创作品转载请注明出处 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-100002900 ...