题意:

  求数字11212312341234512345612345671234567812345678912345678910123456789101112345678910111212345678910111213...的第i位是几?

数位dp打表+二分+暴力模拟

0msAC哦!暴力美学!

 #include <set>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int a[],f[],b[],i_b;
int digit(int x) {
if(x>)return ;
if(x>)return ;
if(x>)return ;
if(x>)return ;
if(x>)return ;
if(x>)return ;
if(x>)return ;
if(x>)return ;
if(x>)return ;
return ;
}
int main() {
int i,j,k;
for(i=; i<=; i++) {
for(j=i; j>=; j--)
if(f[j]) {a[i]+=f[j];break;}
else a[i]+=digit(j);
f[i]=a[i];
a[i]+=a[i-];
}//a[31267]=2147378477
int T,I;
for(scanf("%d",&T); T--;) {
scanf("%d",&I);
int l=,r=;
while(r-l>) {
int mid=(l+r)/;
if(I>a[mid])l=mid;
else if(I==a[mid])l=mid,r=mid;
else r=mid;
}
int cnt=I-a[l],num,ans;
if(!cnt) {cout<<l%<<endl;continue;}
for(i=l+; cnt; i++)
for(j=; j<=i && cnt; j++)
for(num=j,ans=,k=j; k && cnt; k/=,cnt--,ans++);
for(i_b=,k=num; k ; b[++i_b]=k%,k/=);
cout<<b[i_b-ans+]<<endl;
}
return ;
}

C++-1019-Number Sequence的更多相关文章

  1. poj 1019 Number Sequence 【组合数学+数字x的位宽函数】

    题目地址:http://poj.org/problem?id=1019 Number Sequence Time Limit: 1000MS   Memory Limit: 10000K Total ...

  2. Poj 1019 Number Sequence( 数据分析和操作)

    一.题目大意 有这样一个序列包含S1,S2,S3...SK,每一个Si包括整数1到 i.求在这个序列中给定的整数n为下标的数. 例如,前80位为1121231234123451234561234567 ...

  3. POJ 1019 Number Sequence

    找规律,先找属于第几个循环,再找属于第几个数的第几位...... Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submi ...

  4. POJ 1019 Number Sequence 解读

    这是一个看似简单,其实很难受. 本来我想发挥它的标题轨道基础.没想到反被消遣-_-|||. 看它在个人基础上,良好的数学就干脆点,但由于过于频繁,需求将被纳入全,因此,应该难度4星以上. 方法就是直接 ...

  5. POJ - 1019 Number Sequence (思维)

    https://vjudge.net/problem/POJ-1019 题意 给一串1 12 123 1234 12345 123456 1234567 12345678 123456789 1234 ...

  6. PKU 1019 Number Sequence(模拟,思维)

    题目 以下思路参考自discuss:http://poj.org/showmessage?message_id=176353 /*我的思路: 1.将长串数分成一个个部分,每个部分是从1到x的无重复的数 ...

  7. POJ 1019:Number Sequence 二分查找

    Number Sequence Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 36013   Accepted: 10409 ...

  8. HDU 1005 Number Sequence

    Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  9. hdu 1005:Number Sequence(水题)

    Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  10. hdu1005 Number Sequence(寻找循环节)

    主题链接: pid=1005">huangjing 题意: 就是给了一个公式,然后求出第n项是多少... 思路: 题目中n的范围实在是太大,所以肯定直接递推肯定会超时,所以想到的是暴力 ...

随机推荐

  1. 论文阅读笔记(十三)【arxiv2018】:Revisiting Temporal Modeling for Video-based Person ReID

    Introduction (1)Motivation: 当前的一些video-based reid方法在特征提取.损失函数方面不统一,无法客观比较效果.本文作者将特征提取和损失函数固定,对当前较新的4 ...

  2. 48.Python中ORM模型实现mysql数据库基本的增删改查操作

    首先需要配置settings.py文件中的DATABASES与数据库的连接信息, DATABASES = { 'default': { 'ENGINE': 'django.db.backends.my ...

  3. c# 调用c++类库控制usb继电器

    网上找不到调用此类库的文章,简单写一下,以备后用. 下面是封装后的调用c++类库的类 public class UsbRelayDeviceHelper { /// <summary> / ...

  4. C++-POJ3070-Fibonacci-[矩阵乘法][快速幂]

    #include <cstdio> ][];}; ,MOD=1e4; Matrix A,B,O,I; Matrix Mul(Matrix A,Matrix B){ Matrix C=O; ...

  5. 测试用例与PUCCH

  6. 关于Django图片上传

    首先要设置settings # 上传文件 MEDIA_ROOT = 'media' # 项目下的目录 MEDIA_URL = "/media/" # 跟STATIC_URL类似,指 ...

  7. lampp ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'lepus'

    解决方法: 在[mysqlld]段下增加如下代码:skip-grant-tables: 1.which mysql 查看mysql位置,例如:/opt/lampp/bin/mysql 2.进入配置my ...

  8. PHP中关于foreach使用引用变量的坑

    PHP版本为 5.6.12 代码如下:   1 2 3 4 5 6 7 8 9 10 11 12 <?php $arr = ['a', 'b', 'c', 'd', 'e']; foreach ...

  9. 利用redis,为Django项目储存session

    1.准备工作 pip install redis pip install django-redis-sessions==0.5.6 (推荐使用此版本) 创建一个django项目,新建一个booktes ...

  10. ubuntu19.04 redis启动和停止及连接

    1.启动停止 如果以(sudo apt install redis-server)方式安装 启动: sudo srevice redis start 停止:     sudo srevice redi ...