C++-1019-Number Sequence
2024-10-08 11:37:00
题意:
求数字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 ;
}
最新文章
- 漫谈JVM
- 某篇ctr预估ppt的链接
- 如何设置UNIX/Linux中新创建目录或文件的默认权限
- Counting Rectangles
- POJ 3308 Paratroopers(最小割EK(邻接表&;矩阵))
- HDU 1230 火星A+B
- jQuery的选择器中的通配符[id^=&#39;code&#39;] 【转】
- 获取电脑cpu的使用情况
- SQL SERVER的检查点checkpoint
- XJOI练习2神奇的供水系统
- UIDatePicker的使用
- ABP入门系列之1——ABP总体介绍
- 自制操作系统Antz(13) 显示图片
- C语言-第5次作业
- ES6学习笔记(let,const,变量的解构赋值)
- VS2015下安装Entity Framework Power Tools
- python:&#39;ascii&#39; codec can&#39;t encode character
- Css+JS模拟实现可编辑的表格
- TACACS+简单说明
- WireShark 查看UDP码流的丢包率
热门文章
- 2020 CCPC Wannafly Winter Camp Day1 Div.1&;amp F
- centos系统mongodb安装
- gulp常用插件之gulp-babel使用
- Fastbin attack
- 小白月赛22 D : 收集纸片
- Ioc依赖注入:Unity4.0.1 在项目中的应用 (MVC和API)
- XSS漏洞的poc与exp
- 洛谷P3381 MCMF【网络流】
- JSON JavaScriptSerializer 进行序列化或反序列化时出错。字符串的长度超过了为 maxJsonLength 属性设置的值
- Ubuntu18.04安装phpMyAdmin