POJ 2402 Palindrome Numbers
水题,LA我居然没找到在那里。
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <iostream>
using namespace std;
#define LL long long
LL dp[],bin[];
int que[],s;
void judge(int x)
{
s = ;
while(x)
{
que[s++] = x%;
x /= ;
}
}
int main()
{
int i;
LL temp,n,x;
temp = ;
bin[] = ;
for(i = ;i <= ;i ++)
bin[i] = *bin[i-];
for(i = ;i <= ;i ++)
{
if(i% == )
{
dp[i] = temp*;
temp *= ;
}
else
{
dp[i] = dp[i-];
}
}
while(cin>>n&&n)
{
for(i = ;i <= ;i ++)
{
if(n > dp[i])
n -= dp[i];
else
{
if(i == )
cout<<n<<endl;
else if(i == )
cout<<n<<n<<endl;
else if(i% == )
{
x = bin[i/] + n - ;
cout<<x;
judge(x);
for(i = ;i < s;i ++)
cout<<que[i];
cout<<endl;
}
else
{
x = bin[i/-] + n - ;
cout<<x;
judge(x);
for(i = ;i < s;i ++)
cout<<que[i];
cout<<endl;
}
break;
}
}
}
return ;
}
POJ 2402 Palindrome Numbers的更多相关文章
- POJ 2402 Palindrome Numbers(LA 2889) 回文数
POJ:http://poj.org/problem?id=2402 LA:https://icpcarchive.ecs.baylor.edu/index.php?option=com_online ...
- POJ2402/UVA 12050 Palindrome Numbers 数学思维
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example,the ...
- Palindrome Numbers(LA2889)第n个回文数是?
J - Palindrome Numbers Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu ...
- Uva - 12050 Palindrome Numbers【数论】
题目链接:uva 12050 - Palindrome Numbers 题意:求第n个回文串 思路:首先可以知道的是长度为k的回文串个数有9*10^(k-1),那么依次计算,得出n是长度为多少的串,然 ...
- Poj 2247 Humble Numbers(求只能被2,3,5, 7 整除的数)
一.题目大意 本题要求写出前5482个仅能被2,3,5, 7 整除的数. 二.题解 这道题从本质上和Poj 1338 Ugly Numbers(数学推导)是一样的原理,只需要在原来的基础上加上7的运算 ...
- E - Palindrome Numbers
题目链接:https://vjudge.net/contest/237394#problem/E A palindrome is a word, number, or phrase that read ...
- POJ 1159 Palindrome(字符串变回文:LCS)
POJ 1159 Palindrome(字符串变回文:LCS) id=1159">http://poj.org/problem? id=1159 题意: 给你一个字符串, 问你做少须要 ...
- UVa 12050 - Palindrome Numbers (回文数)
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, th ...
- POJ 3974 Palindrome
D - Palindrome Time Limit:15000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Sub ...
随机推荐
- MyEclipse2014配置Tomcat开发JavaWeb程序JSP以及Servlet(转载)
转载地址:http://blog.csdn.net/21aspnet/article/details/21867241 1.安装准备 1).下载安装MyEclipse2014,这已经是最新版本. 2) ...
- 【翻译二十一】java-并发之分拆和合并
Fork/Join This section was updated to reflect features and conventions of the upcoming Java SE 8 rel ...
- 六款小巧的HTTP Server[C语言]
1.micro_httpd - really small HTTP server特点: 支持安全的 .. 上级目录过滤 支持通用的MIME类型 支持简单的目录 支持目录列表 支持使用 index.ht ...
- SQLServer 维护脚本分享(08)临时数据库(tempdb)
dbcc sqlperf(logspace) --各数据库日志大小及使用百分比 dbcc loginfo --查看当前数据库的虚拟日志文件 --临时表'Tempdb'最近使用情况 SELECT t1. ...
- C# 插件式程序开发
在网上找了下插件式编程的资料,这里自己先借鉴下别人的,同时发现有自己的看法,不过由于本人水平有限,不一定有参考价值,写出来一方面是为了总结自己,以求提高,另一方面也希望各为朋友看到我的不足,给我提出宝 ...
- css3易混淆属性详解
1.background, background-color, color (1)background:在一个声明中设置所有属性: 如:background: #00FF00 url(bgima ...
- 性能优化之Java(Android)代码优化
最新最准确内容建议直接访问原文:性能优化之Java(Android)代码优化 本文为Android性能优化的第三篇——Java(Android)代码优化.主要介绍Java代码中性能优化方式及网络优化, ...
- Codeforces Round #356 (Div. 2)-A
A. Bear and Five Cards 题目链接:http://codeforces.com/contest/680/problem/A A little bear Limak plays a ...
- Js判断客户端是iphone还是安卓
<script> var u = navigator.userAgent; var isAndroid = u.indexOf('Android') > -1 || u.indexO ...
- Tactical Multiple Defense System 二分图
This problem is about a war game between two countries. To protect a base, your country built a defe ...