//侥幸AC了 #include <stdio.h>   #include <math.h>   #include <stdlib.h>   int Get(int n){ int x; int lo = 1, start = 1, end = 9; double p10 = 10.0; while (1){ int temp = (start + end) * 9 * pow(p10, lo - 1) / 2; if (temp > n)  break; n -= temp; lo++; start = end + lo; end = start + lo*pow(p10, lo - 1) * 9; } while (1){ if (start >= n) break; n -= start; start += lo; } start = 9; lo = 1; while (1){ if (start > n) break; n -= start; lo++; start = 9 * pow(p10, lo - 1)*lo; } start = 9 * pow(p10, lo - 2)*(lo-1) + n / lo; stringstream str; str<<start; x = str[n%lo] - '0'; return x; } int main() { int n; scanf("%d", &n); int r = Get(n); printf("%d\n", r); }
点赞 评论

相关推荐

点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务