UVA - 12050-Palindrome Numbers
12050 - Palindrome Numbers
Time limit: 3.000 seconds
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, the name “anna” is a palindrome. Numbers can also be palindromes (e.g. 151 or 753357). Additionally numbers can of course be ordered in size. The first few palindrome numbers are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, ... The number 10 is not a palindrome (even though you could write it as 010) but a zero as leading digit is not allowed.
Input
The input consists of a series of lines with each line containing one integer value i (1 ≤ i ≤ 2∗109). This integer value i indicates the index of the palindrome number that is to be written to the output, where index 1 stands for the first palindrome number (1), index 2 stands for the second palindrome number (2) and so on. The input is terminated by a line containing ‘0’.
Output
For each line of input (except the last one) exactly one line of output containing a single (decimal) integer value is to be produced. For each input value i the i-th palindrome number is to be written to the output.
Sample Input
1
12
24
0
Sample Output
1
33
151
题意就是把第i个回文数输出来。
长度为k的回文数有9*10(k-1)个,依次计算,得出n为长度多少的回文数,然后得出长度多少的第几个回文数,n计算完要-1.
1-9 9
10-99 9
100-999 90
1000-9999 90
然后900 900 9000 9000。。。
这个题好像又不会了。。。
傻子(╯‵□′)╯︵┻━┻,用C语言交了10几次,格式错误,都不知道看一下用什么交的吗?(▼ヘ▼#)
代码:
#include<stdio.h>
const int N=*1e5;
int n[N],i;
int h,m[N];
void gg(){
n[]=,n[]=n[]=;
for(i=;i<;i+=)
n[i]=n[i+]=n[i-]*;
}
int main(){
gg();
while(~scanf("%d",&h)&&h){
int len=;
while(h>n[len]){
h-=n[len];
len++;
}
h--;
int cnt=len/+;
while(h!=){
m[cnt++]=h%;
h/=;
}
for(i=cnt;i<=len;i++)
m[i]=;
m[len]++;
for(i=;i<=len/;i++){
m[i]=m[len-i+];
}
for(i=;i<=len;i++)
printf("%d",m[i]);
printf("\n");
}
return ;
}
UVA - 12050-Palindrome Numbers的更多相关文章
- Uva - 12050 Palindrome Numbers【数论】
题目链接:uva 12050 - Palindrome Numbers 题意:求第n个回文串 思路:首先可以知道的是长度为k的回文串个数有9*10^(k-1),那么依次计算,得出n是长度为多少的串,然 ...
- POJ2402/UVA 12050 Palindrome Numbers 数学思维
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example,the ...
- UVa 12050 - Palindrome Numbers (回文数)
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, th ...
- UVA 12050 - Palindrome Numbers 模拟
题目大意:给出i,输出第i个镜像数,不能有前导0. 题解:从外层开始模拟 #include <stdio.h> int p(int x) { int sum, i; ;i<=x;i+ ...
- UVa - 12050 Palindrome Numbers (二分)
Solve the equation: p ∗ e −x + q ∗ sin(x) + r ∗ cos(x) + s ∗ tan(x) + t ∗ x 2 + u = 0 where 0 ≤ x ≤ ...
- UVa 10006 - Carmichael Numbers
UVa 10006 - Carmichael Numbers An important topic nowadays in computer science is cryptography. Some ...
- Palindrome Numbers(LA2889)第n个回文数是?
J - Palindrome Numbers Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu ...
- 2017ecjtu-summer training #1 UVA 12050
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, th ...
- UVa - 12050
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example,the ...
- UVA.136 Ugly Numbers (优先队列)
UVA.136 Ugly Numbers (优先队列) 题意分析 如果一个数字是2,3,5的倍数,那么他就叫做丑数,规定1也是丑数,现在求解第1500个丑数是多少. 既然某数字2,3,5倍均是丑数,且 ...
随机推荐
- SLAM入门之视觉里程计(2):两视图对极约束 基础矩阵
在上篇相机模型中介绍了图像的成像过程,场景中的三维点通过"小孔"映射到二维的图像平面,可以使用下面公式描述: \[ x = MX \]其中,\(c\)是图像中的像点,\(M\)是一 ...
- Search an Element in an array
Given an integer array and an element x, find if element is present in array or not. If element is p ...
- bzoj 3192: [JLOI2013]删除物品
Description 箱子再分配问题需要解决如下问题: (1)一共有N个物品,堆成M堆. (2)所有物品都是一样的,但是它们有不同的优先级. (3)你只能够移动某堆中位于顶端的物品. ( ...
- 使用 Kafka 和 ELK 搭建测试日志系统(1)
本文仅供自己学习,不合适转载. 这是两篇文章的第一部分. 1. 安装 ELK 1.1 安装 ElasticSearch 在海航云上创建一个 Ubutu 16.4 虚机,2核4GB内存. (1)执行以下 ...
- 2、各种折腾,安装交叉环境的gcc和qt,测试c++和qt程序
本博文仅作本人操作过程的记录,留作备忘.自强不息 QQ1222698 1.安装gcc和qt 把光盘里带的gcc-4.4.4-glibc-2.11.1-multilib-1.0_EasyARM-iMX2 ...
- centos 命令
1.查看占用端口的进程 netstat -lnp|grep 3000(3000为端口号) Netstat 命令用于显示各种网络相关信息,如网络连接,路由表,接口状态 (Interface Statis ...
- mybatis的知识点
mybatis核心配置文件的配置 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE conf ...
- vue-router源码学习(一)
因为v3.01版本中的 /src代码使用TypeScript进行书写,我这里仅仅用作模块学习, 具体学习的还是 /dist/vue-router.js 代码. (一)基本使用方式 JS代码 // ...
- 【JDK1.8】JDK1.8集合源码阅读——LinkedList
一.前言 这次我们来看一下常见的List中的第二个--LinkedList,在前面分析ArrayList的时候,我们提到,LinkedList是链表的结构,其实它跟我们在分析map的时候讲到的Link ...
- Android -- NestedScrolling滑动机制
1,如今NestedScrolling运用到很多地方了,要想好看一点的滑动变换,基本上就是使用这个来完成的,让我们来简单的了解一下. 2,NestedScrolling机制能够让父View和子View ...