CodeForces-672A-Summer Camp

来源:互联网 发布:snapchat网络无法连接 编辑:程序博客网 时间:2024/06/05 05:37

Description

Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems.

This is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one line. The prefix of these line is “123456789101112131415…”. Your task is to print the n-th digit of this string (digits are numbered starting with 1.

Input

The only line of the input contains a single integer n (1 ≤ n ≤ 1000) — the position of the digit you need to print.

Output

Print the n-th digit of the line.

Sample Input
Input

3

Output

3

Input

11

Output

0

就是12345678910111213……问你第几位是那个数

#include<iostream>  #include<stdio.h>  #include<cstring>  #include<string>  #include<algorithm>  using namespace std;   const int MAXN=2000+5;  #define INF 0x3f3f3f3f  int digit[MAXN],tmp[MAXN];  void init(){      int cnt=1;      for(int i=1; cnt<=1000; i++){          int num=i, tmpcnt=0;          while(num){              tmp[++tmpcnt]=num%10;              num/=10;          }          while(tmpcnt>=1){              digit[cnt++]=tmp[tmpcnt--];          }      }  }  int main()  {      int n;      init();      while(scanf("%d",&n)!=EOF){          printf("%d\n",digit[n]);      }  return 0;  }  
0 0
原创粉丝点击