CodeForces 672A Summer Camp
2016-05-14 20:37
441 查看
思路:水题
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
Output
Input
Output
#include<bits\stdc++.h> using namespace std; int main() { string s = ""; int i = 1; while(s.size()<1000) { string s1 = ""; int temp = i; while(temp) { s1+=(temp%10+'0'); temp/=10; } reverse(s1.begin(),s1.end()); s+=s1; i++; } int n; scanf("%d",&n); printf("%c\n",s[n-1]); }
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
相关文章推荐
- Hbase遇到的问题Unable to move table from temp重新格式化hbase
- 匿名函数和字面量——JS学习
- zoj3662 dp 离散优化
- 1096. Consecutive Factors (20)——PAT (Advanced Level) Practise
- poj 1836
- JS 将字符串转换成日期类型
- 面向对象的登录系统(QQ登录窗体)
- C++_(矩阵)快速幂
- swift 利用 Reflect(字典转模型)
- httpClient Post 加号会被转换为空格
- 【数据库】where 1=1 和 where 1=0
- HDU 2553 N皇后问题 (DFS)
- 第10、11周程序阅读 继承和派生 1
- 零售行业常见数据分析简介
- SSIS 学习之旅 第一个SSIS 示例(二)
- Android ActionBarSherlock使用教程
- ST表学习
- Apache Flink源码解析之stream-transformation
- Linux 文件系统剖析
- 1095. Cars on Campus (30)——PAT (Advanced Level) Practise