Title: http://poj.org/problem?id=1019
Solution:
Preprocess the length of $cnt (i) $ for $s_i$, $S (i) $ for $cnt (i) $ for the prefix and, in this case, for a coordinate n, to get a string of length n, we can divide it into $s_1,s_2....s_{k-1}$ and not necessarily complete $s_k$. Dichotomy $s (i) $ with $n$ minus the corresponding $s (t) $ to get the length of the incomplete string $s_k$
Next, the $s_k$ is divided into two parts, part of which is the complete number, and part of it is not necessarily a complete number. For example: 1 and 10 in 1234567891,12345678910, and the same treatment as above.
The problem is converted to the T-bit of the number x, which can be simulated.
#include <cstdio>#include<cstring>#include<cmath>#defineN 100010#defineLD Double#defineLL Long Longusing namespacestd;intCnt[n],tot,num[n]; LL S[n];intGet_num (intXintt) {Tot=0; for(intI=x;i;i/=Ten) num[++tot]=i%Ten; returnnum[tot-t+1];}intCalcintN) { for(intI=1; i<n;i++) if(n<=S[i]) {N-=s[i-1]; Break; } intIPOs; for(intI=1; i<n;i++) if(n<=Cnt[i]) {N-=cnt[i-1]; IPOs=i; Break; } returnGet_num (ipos,n);}intMain () { for(intI=1; i<n;i++) {Cnt[i]=cnt[i-1]+(int) log10 ((LD) i) +1; S[i]=s[i-1]+Cnt[i]; } intT,n; scanf ("%d",&T); while(t--) {scanf ("%d",&N); printf ("%d\n", Calc (n)); } return 0;}View Code
POJ 1019 Number Sequence