数论 UVAlive 2889
这是一道考察回文数的题目,要求你输出第k个回文数。在做题的过程中,可以发现回文数的分布的规律:一位数:9个,二位数:9个,三位数:90个,四位数:90个,五位数:900个,六位数:900个……。
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
int main()
{
int n;
while(scanf("%d",&n)&&n)
{
long long x=0;
while(n>x*2)
x=x*10+9;
if(n>x+x/10)
{
n-=x;
printf("%d",n);
while(n>0)
{
printf("%d",n%10);
n/=10;
}
}
else
{
n-=x/10;
printf("%d",n);
n/=10;
while(n>0)
{
printf("%d",n%10);
n/=10;
}
}
printf("\n");
}
return 0;
}
数论 UVAlive 2889的更多相关文章
- 数论 UVALive 2756
这道题目考察的n个不同的数环形排列,每次相邻两个数交换位置,这样由正序转变成逆序所需操作的最小次数t. 公式:环形排列:t= n/2*(n/2 - 1)/2 + (n+1)/2* ((n+1)/2 - ...
- 数论 UVALive 2911
这道题是一道数论题. 题目的意思是告诉m.p.a.b,并且告诉你xi满足的两个条件.让你求出 xp1 + xp2 +...+ xpm 的最大值(其中p<=12,切p是偶数). 这里需要对于xi所 ...
- UVALive 2889(回文数字)
题意:给定i,输出第i个回文数字. 分析:1,2,3,4,……,9------------------------------------------------------------------- ...
- Palindrome Numbers(LA2889)第n个回文数是?
J - Palindrome Numbers Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu ...
- Gym 100299C && UVaLive 6582 Magical GCD (暴力+数论)
题意:给出一个长度在 100 000 以内的正整数序列,大小不超过 10^ 12.求一个连续子序列,使得在所有的连续子序列中, 它们的GCD值乘以它们的长度最大. 析:暴力枚举右端点,然后在枚举左端点 ...
- UVa 12716 && UVaLive 6657 GCD XOR (数论)
题意:给定一个 n ,让你求有多少对整数 (a, b) 1 <= b <= a 且 gcd(a, b) = a ^ b. 析:设 c = a ^ b 那么 c 就是 a 的约数,那么根据异 ...
- Codeforces Round #382 Div. 2【数论】
C. Tennis Championship(递推,斐波那契) 题意:n个人比赛,淘汰制,要求进行比赛双方的胜场数之差小于等于1.问冠军最多能打多少场比赛.题解:因为n太大,感觉是个构造.写写小数据, ...
- UVALive - 4108 SKYLINE[线段树]
UVALive - 4108 SKYLINE Time Limit: 3000MS 64bit IO Format: %lld & %llu Submit Status uDebug ...
- UVALive - 3942 Remember the Word[树状数组]
UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...
随机推荐
- The Managed Metadata Service or Connection is currently not available 分类: Sharepoint 2015-07-09 13:28 5人阅读 评论(0) 收藏
Does the following error message looks familiar to you? (When you go to Site Actions –> Site Sett ...
- C++多线程1
一个多线程的实例 #include "stdafx.h" #include <windows.h> DWORD __stdcall Func(LPVOID pm) { ...
- 对contentoffset的理解
今天遇到一个问题,在写瀑布流时,竖屏的时候可以正常实现,在手机变成横屏后,总是显示不全. 最终查了两个小时,查到了导致这个的原因,是自己的判断cell是否在当前显示区域的方法写错了. 根本原因是没有很 ...
- 百度地图结合echarts并添加行政区块
作者:LJaer链接:https://www.zhihu.com/question/49251513/answer/125728764来源:知乎<!DOCTYPE html> <ht ...
- MYSQL单双向同步
Master:192.168.1.101 Slave :192.168.1.102 单向同步(一) 进入Master启动MYSQL [root@localhost ~]# service mysql ...
- <textarea>使用的时候发现的两个问题的总结
在练习表单的过程中,使用<textarea>时,遇到2个问题: 1.文本开始前有好多空格. 原来的代码是这样的: <textarea row="20" col=& ...
- em 和 px相互转换
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- (转) 浅析HTML5在移动应用开发中的使用
(转)浅析HTML5在移动应用开发中的使用 (原)http://www.iteye.com/magazines/67 2012-03-07 来自 UECD.163.com 编辑 wangguo ...
- sync_with_stdio
/* The synchronization referred to is @e only that between the standard * C facilities (e.g., stdout ...
- Selenium 2 入门
在多个浏览器中进行 Web 应用程序的端到端功能测试 Selenium 是一款有名的 Web 应用程序测试框架,用于进行功能测试.新版本 Selenium 2 结合了 Selenium 1 和 Web ...