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倍均是丑数,且 ...
随机推荐
- 使用node的fs读取文件
啊啊啊啊啊啊啊啊啊啊啊啊啊啊,被node的fs坑了一下午,我又爬上来了,要坚强的笑着活下去,嗯,没毛病老铁. let http = require('http'); let fs = require( ...
- Spring(概念)
在本文中只讲述一些概念性的东西,因为我在开始学习JAVA的时候对这些概念性的东西总是不太理解,总结总结再感悟一下,也方便后人. 理解的不深,用通俗的语言讲一下: 百度百科这样介绍: spring框架主 ...
- 开启tomcat的apr模式,并利用redis做tomcat7的session的共享。
更新系统组件 yum -y install readline* xmlto kernel-devel yum* screen vim* psmisc wget lrzsz pcre-devel lib ...
- bzoj 1150: [CTSC2007]数据备份Backup
Description 你在一家 IT 公司为大型写字楼或办公楼(offices)的计算机数据做备份.然而数据备份的工作是枯燥乏味 的,因此你想设计一个系统让不同的办公楼彼此之间互相备份,而你则坐在家 ...
- JavaScript连等赋值
最近探究js原理的过程中遇到了这个挺有趣的问题. 先贴代码: var a = {n:1} a.x = a = {n:2} alert(a.x) //undefined 在弄懂这个之前,我们先普及一个知 ...
- lesson - 8 课程笔记 tar / gzip /bzip2 / xz /
作用:为linux的文件和目录创建档案,也可以在档案中改变文件,或者向档案中加入新的文件即用来压缩和解压文件.tar本身不具有压缩功能.他是调用压缩功能实现的 语法:tar[必要参数][选择参数][ ...
- 限制ssh远程登陆
超过十次,就添加到hosts.deny里面去 #!/bin/bash date=`date +%Y%m%d` file="/var/log/secure" max=10 if [[ ...
- 关于swing的一些问题
-问题1 :Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1 & ...
- selenium自动化测试打开新标签窗口
做项目自动化测试时遇到这个问题:先打开一个页面需要在现有打开浏览器的基础上新开一个标签页输入网址, 在网上查了很多无果,后来发现了内嵌js代码,让js代码实现的方式.谁有其他方法的可以共享一下 方法如 ...
- 使用linux perf工具生成java程序火焰图
pre.cjk { font-family: "Nimbus Mono L", monospace } p { margin-bottom: 0.1in; line-height: ...