codeforces 672A Summer Camp
来源:互联网 发布:apache cgi bin 编辑:程序博客网 时间:2024/06/06 04:39
点击打开链接
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.
The only line of the input contains a single integer n (1 ≤ n ≤ 1000) — the position of the digit you need to print.
Print the n-th digit of the line.
3
3
11
0
In the first sample the digit at position 3 is '3', as both integers 1 and 2 consist on one digit.
In the second sample, the digit at position 11 is '0', it belongs to the integer 10.
把数字转化成字符串。转化博客
#include<bits/stdc++.h>#include<cstdlib>using namespace std;template<typename T> string toString(const T& t){ ostringstream oss; //创建一个格式化输出流 oss<<t; //把值传递如流中 return oss.str();}int main(){ string str; int i=1; string s; while(1) { s=toString(i); str=str+s; if(str.length()>=1000) break; i++; } int n; scanf("%d",&n); cout<<str[n-1]<<endl; return 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]平方运算
- 眼底图像血管增强与分割--(5)基于Hessian矩阵的Frangi滤波算法
- Android自定义view画圆和view组合
- cocos3.10俄罗斯方块规则核心源码
- Spring集成Jersey开发,实现rest约束例子
- CCF考试——201609-1最大波动
- codeforces 672A Summer Camp
- html浮动定位相关知识
- c语言实现两个数的平均值
- OKHTTP3的封装
- ros-i节点代码
- 分IP统计访问次数(Fileter和Listener)
- node启动管理
- spring注解扫描
- div布局,哈哈有点丑