[CF1177B]Digits Sequence (Hard Edition)题解
一个简单的模拟,首先先计算当前是几位数,然后根据几位数推断当前的数是什么,然后求出该位即可
#include <cstdio>
int main(){
long long k; scanf("%lld", &k);
long long cur = 1, cnt = 9;
while (cur * cnt < k){k -= cur * cnt; cnt *= 10, ++cur;}
long long mod = k % cur, a = (k - 1) / cur;
if (!mod) mod = cur;
long long num = 1;
for (int i = 1; i < cur; ++i) num *= 10;
num += a;
for (int i = 1; i <= (cur - mod); ++i) num /= 10;
printf("%lld", num % 10);
return 0;
}