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 ...
随机推荐
- jquery选择器练习
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...
- uC/OS-III 时钟节拍,时间管理,时间片调度
uC/OS-III 时钟节拍,时间管理,时间片调度 时钟节拍 时钟节拍可谓是 uC/OS 操作系统的心脏,它若不跳动,整个系统都将会瘫痪. 时钟节拍就是操作系统的时基,操作系统要实现时间上的管理, ...
- Android WebView漏洞(转)
一.漏洞描述 近期,微信等多款安卓流行应用曝出高危挂马漏洞:只要点击好友消息或朋友圈中的一条网址,手机就会自动执行黑客指令,出现被安装恶意扣费软件.向好友 发送欺诈短信.通讯录和短信被窃取等严重后果. ...
- WPF绑定文本时使用指定格式文本
原文:WPF绑定文本时使用指定格式文本 Text="{Binding PlayletModel.characters,StringFormat=Cast : {0}}" Strin ...
- jenkis +sonarqube 对后端代码静态扫描,钉钉群通知执行结果(记录)
代码提交,触发后端sonar测试,测试完成,jenkins触发依赖任务,执行python脚本,达到预期,调用上线任务模块,进行上线,达不到预期,钉钉群通知. 牵涉到配置: 1.配置sonar测试任务 ...
- Docker_容器化gitlab
Docker部署接口自动化持续集成环境第一步,容器化一个Gitlab! 1:开放防火墙端口 sudo yum install curl openssh-server openssh-clients p ...
- Asp.Net_Wcf跟Wpf的区别
摘要:WCF,你就先把它想成WebService的下一代也没什么问题.WCF为WindowsCommunicationFoundation,是Microsoft为构建面向服务的应用提供的分布式通信编程 ...
- Js_特效
事件源对象 event.srcElement.tagName event.srcElement.type 捕获释放 event.srcElement.setCapture(); event.srcE ...
- DICOM 协议学习笔记之 How Does DICOM Work ?
How Does DICOM Work ? DICOM有一套自己自己的模型体系,在进行具体介绍之前,首先讲解下DICOM模型: 在DICOM世界当中,所有的包括患者.检查.医学设备等都可以被视为具有不 ...
- 前后端同学必会的Linux基础命令
无论是前端还是后端同学,一些常用的linux命令还是必须要掌握的.发布版本.查看日志等等都会用到.以下是我简单的总结了一些简单又常用的命令,欢迎大家补充.希望能帮助到大家 基础篇 1.进入目录 cd ...