#include <iostream>
#include <string>
using namespace std;
int findNthDigit(int n) {
int digits = 1; // 当前数字位数
long long count = 9; // 当前位数数字的总位数
int start = 1; // 当前位数数字的开始数字
// 1. 确定数字位数
while (n > count) {
n -= count;
digits++;
start *= 10;
count = 9 * start * digits;
}
// 2. 确认具体数字
int num = start + (n - 1) / digits;
// 3. 确定数字中的具体位
int digit_pos = (n - 1) % digits;
return to_string(num)[digit_pos] - '0';
}
int main() {
int n;
cin >> n;
cout << findNthDigit(n) << endl;
}

京公网安备 11010502036488号