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
- CodeForces 672A Summer Camp
- CodeForces-672A-Summer Camp
- CodeForces 672A Summer Camp
- [CodeForces]-672A-Summer Camp
- codeforces 672A Summer Camp
- CodeForces 672A Summer Camp 【sprintf】
- CodeForces - 672A Summer Camp (模拟)水
- CodeForces 672A Summer Camp(数字游戏,枚举)
- A. Summer Camp
- Codeforces Round #352 (Div. 2) A.Summer Camp
- Codeforces Round #352 (Div. 2) A. Summer Camp __ water problem
- Codeforces Round #352 (Div. 2)-Summer Camp(模拟)
- Microsoft .NET Summer Camp
- codeforces_672A. Summer Camp(string)
- ecjtu-summer training #1 A(CodeForces 651A)
- Summary about summer camp of BeiHang University
- BZOJ4104 [Thu Summer Camp 2015]解密运算
- [BZOJ4105][Thu Summer Camp 2015]平方运算
- xml—约束(DTD)
- 玩转Android Studio
- ScrollView嵌套listView问题
- Apache Maven 入门篇(下)
- 设置UIView圆角的拓展
- CodeForces-672A-Summer Camp
- 根据B表数据更新A表
- CocurrentHashMap和Hashtable的区别
- 网络编程(二)
- MFC 基于多文档的打印和打印预览功能的实现
- Python 面向对象 —— 特殊函数
- Android关于透明度对应表
- RTTI
- Box2D C++ 教程-Testbed结构