Number Sequence--POJ1019
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 35251 | Accepted: 10151 |
Description
For example, the first 80 digits of the sequence are as follows:
11212312341234512345612345671234567812345678912345678910123456789101112345678910
Input
Output
Sample Input
2
8
3
Sample Output
2
2
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define N 32000
using namespace std;
int main()
{
int a[]= {,,,,,,,,};
long long b[N]= {},n,sum=;
int i,T,m,j,l,A,B;
for(i=; i<N; i++)
{
if(i<=)
b[i]=i;
else
{
m=;
l=(int)log10(i)+;
for(j=; j<l; j++)
{
m=m*+;
}
b[i]=(i-m)*l+b[m];
}
// sum+=b[i];
}
// printf("%lld\n",sum);确定b数组的范围,即N的大小;
scanf("%d",&T);
while(T--)
{
scanf("%lld",&n);
for(i=;i<N;i++)
{
if(n>b[i])
{
n-=b[i];
}
else
{
break;
}
}
for(i=;i<;i++)
{
if(n>a[i])
n-=a[i];
else
break;
}
A=n/i;
B=n%i;
if(B!=)
A+=;
else
B=i;
m=;
for(j=;j<i;j++)
m=m*+;
A=A+m;
char str[]= "";
sprintf(str,"%d",A);
printf("%c\n",str[B-]);
}
return ;
}
Number Sequence--POJ1019的更多相关文章
- POJ1019——Number Sequence(大数处理)
Number Sequence DescriptionA single positive integer i is given. Write a program to find the digit l ...
- POJ1019 Number Sequence
Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36256 Accepted: 10461 ...
- HDU 1005 Number Sequence
Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- POJ 1019 Number Sequence
找规律,先找属于第几个循环,再找属于第几个数的第几位...... Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submi ...
- HDOJ 1711 Number Sequence
Number Sequence Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Number Sequence
Number Sequence A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) ...
- [AX]AX2012 Number sequence framework :(三)再谈Number sequence
AX2012的number sequence framework中引入了两个Scope和segment两个概念,它们的具体作用从下面序列的例子说起. 法国/中国的法律要求财务凭证的Journal nu ...
- KMP - HDU 1711 Number Sequence
Number Sequence Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 1005:Number Sequence(水题)
Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Number Sequence 分类: HDU 2015-06-19 20:54 10人阅读 评论(0) 收藏
Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...
随机推荐
- linux 端口占用情况
1,查看8010端口是否被占用 [root@cloud ~]# netstat -an|grep 8010 tcp 0 0 0.0.0.0:8010 0.0.0.0:* LISTEN 2,查看8010 ...
- iOS开发-NSDictionary
判断一个字典中是否存在某个key,有两种方法: 方法一: if ([dictionary allKeys] containsObject: key]){ // cotains key operatio ...
- Linux 常用文件
/etc/exports /etc/services /etc/sysctl.conf /etc/logrotate.conf /etc/docker/key.json /etc/docker/dae ...
- CentOS7--使用yum安装和管理软件
yum是红帽软件包管理器,它能能够查询,安装和卸载软件包,以及将整个系统更新到最新的可用版本.Yum可以在安装的过程中自动解决依赖关系. 1. 检查和更新软件包 1.1 查询更新 查看系统上哪些已安装 ...
- C++ template —— trait与policy类(七)
第15章 trait与policy类---------------------------------------------------------------------------------- ...
- 普通for循环和增强for循环的区别
1.普通for循环:自行维护循环次数,循环体自行维护获取元素的方法: int[] array = new int[]{1,2,3,4,5}; //int[] array ={1,2,3,4,5} ; ...
- Matlab练习——寻找完全数
clc; clear; wq = []; : sum = ; k = ; : i / sum = sum + j; end end == i wq=[wq i]; end end disp(['2至1 ...
- php原生实现图片上传和查看
先上源码:upload_file.php <html> <body> <form action="upload_file.php" method=&q ...
- echarts.js多图表数据展示使用小结
echarts api文档: http://echarts.baidu.com/echarts2/doc/doc.html echarts demo示例: http://echarts.baidu.c ...
- String 类实现 以及>> <<流插入/流提取运算符重载
简单版的String类,旨在说明>> <<重载 #include <iostream> //#include <cstring>//包含char*的字符 ...