poj 1019
懂了
题意是给一串 1 12 123 1234 12345 123456 。。。。这样的数字问第
i个数字是多少
Sample Input
2
8
3
Sample Output
2
2
#include<math.h>
#include<cstdio>
#include<iostream>
using namespace std;
unsigned int a[],s[]; //a是到第i个数字的位数,s是第i组的位数
void reset()//打表
{
int i;
a[]=;
s[]=;
for(i=;i<;i++)
{
a[i]=a[i-]+(int)log10((double)i)+;
s[i]=s[i-]+a[i];
}
/*for(i=1;i<=100;i++)
{
printf("%d ",a[i]);
}
printf("\n");
for(i=1;i<=100;i++)
{
printf("%d ",s[i]);
}*/
} int main()
{
int T;
int n;
int i;
scanf("%d",&T);
reset();
while(T--)
{
scanf("%d",&n);
i=; while(s[i]<n) i++; /* 找到 n 所在的组 */ int pos=n-s[i-]; /* n 在该组的下标 */
int tmp=;
for(i=;tmp<pos;i++) /* length: n指向的数字的最后一位的下标 */
{
tmp+=(int)log10((double)i)+;
}
printf("%d %d\n",pos,tmp);
int k=tmp-pos;
printf("%d\n",(i-)/(int)pow(10.0,k)%) ;/*从右向左求,比如123456,k=2,则结果为4*/ /* 去掉所求位后面的数字然后取余 */
/* i: n指向的数字 + 1 */ }
return ; }
poj 1019的更多相关文章
- Poj 1019 Number Sequence( 数据分析和操作)
一.题目大意 有这样一个序列包含S1,S2,S3...SK,每一个Si包括整数1到 i.求在这个序列中给定的整数n为下标的数. 例如,前80位为1121231234123451234561234567 ...
- poj 1019 Number Sequence 【组合数学+数字x的位宽函数】
题目地址:http://poj.org/problem?id=1019 Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total ...
- POJ 1019:Number Sequence 二分查找
Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36013 Accepted: 10409 ...
- POJ 1019 Number Sequence
找规律,先找属于第几个循环,再找属于第几个数的第几位...... Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submi ...
- POJ 1019 Number Sequence 解读
这是一个看似简单,其实很难受. 本来我想发挥它的标题轨道基础.没想到反被消遣-_-|||. 看它在个人基础上,良好的数学就干脆点,但由于过于频繁,需求将被纳入全,因此,应该难度4星以上. 方法就是直接 ...
- Number Sequence POJ - 1019 递推 数学
题意 1 12 123 1234 12345 ....这样的序列 问第n位数字是几 是数字! 1-9! 思路:递推关系 主要是位数的计算 用a[i]=a[i-1]+(int)log10((do ...
- POJ - 1019 Number Sequence (思维)
https://vjudge.net/problem/POJ-1019 题意 给一串1 12 123 1234 12345 123456 1234567 12345678 123456789 1234 ...
- Number Sequence(poj 1019)
题意: 有一串数字串,其规律为 1 12 123 1234 12345 123456 1234567 12345678 123456789 12345678910 1234567891011 1234 ...
- POJ 1019 数学题
#include <cstdio> #include <cstring> using namespace std; ]; //sum[i]表示尾数为i的组最大可达到的数字个数 ...
随机推荐
- 【MVC5】ASP.NET MVC 项目笔记汇总
ASP.NET MVC 5 + EntityFramework 6 + MySql 先写下列表,之后慢慢补上~ 对MySql数据库使用EntityFramework 使用域用户登录+记住我 画面多按钮 ...
- WebSocket 是什么原理?为什么可以实现持久连接?
https://www.zhihu.com/question/20215561 作者:Ovear链接:https://www.zhihu.com/question/20215561/answer/ ...
- bootstrap 新手学习笔记 代码整理
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- Windows部署WordPress
感谢原文作者,还是给个快速通道: http://www.cnblogs.com/huangcong/archive/2010/03/31/1701052.html 另:安装之后,运行速度会很慢,以下是 ...
- VirtualBox 网络设置
VirtualBox是什么 VirtualBox 是一款 x86 虚拟机软件.原由德国innotek公司开发,2008年Sun收购了Innotek,而Sun于2010年被Oracle收购,2010年1 ...
- intel 系列的PC机处理器是大端的还是小端的?
intel 系列的PC机处理器是大端的还是小端的?由于要安装oracle,需要知道是大端机器还是小端的,你好,现在流行的PC,是微型处理器,也就是所谓的小端处理器. 大端处理器是由若干个微型处理器有机 ...
- wordpress编辑主题时报错Warning: scandir() has been disabled for security reasons in
在ubuntu下面安装了一个wordpress程序,在后台什么都没干,编辑主题时,发现页面中报下面的错误. notice: /home/wwwroot/test.localhost/wordpress ...
- SQL例题合集
1. 查询Student表中的所有记录的Sname.Ssex和Class列. Select sname,ssex,class from student; 2. 查询教师所有的单位即不重复的Depart ...
- hibernate中的session缓存
1.什么是session缓存? 在 Session 接口的实现中包含一系列的 Java 集合, 这些 Java 集合构成了 Session 缓存. 只要 Session 实例没有结束生命周期, 且没有 ...
- IOC原理解释
spring ioc它其实是一种降低对象耦合关系的设计思想,通常来说,我们在一个类调用另一个类的方法的时候,需要不断的new新的对象来调用该方法,类与类之间耦合度比较高,有了ioc容器以后,ico容器 ...