Codeforces Round #352 (Div. 2)(A)模拟

原创 2016年05月31日 17:52:40

A. Summer Camp
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Examples
input
3
output
3
input
11
output
0
Note

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.




题意:给你一个由1 2 3 4。。。。。组成的字符串,问第n位是什么数字?


题解:由于你n<=1e3直接模拟就好啦



import java.lang.*;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		Scanner in = new Scanner(System.in);
		String s = new String();
		for(int i=1;i<=1000;i++)
		{
			s = s + i ;
		}
		int n;
		n=in.nextInt();
		System.out.println(s.charAt(n-1));
	}

}




版权声明:本文为博主原创文章,你若想转载请附上源博客地址。

相关文章推荐

Codeforces Round #352 (Div. 2)-B. Different is Good(模拟)

B. Different is Good time limit per test 2 seconds memory limit per test 256 megabytes ...

Codeforces Round #352 (Div. 2) C. Recycling Bottles (几何)

C. Recycling Bottlestime limit per test 2 seconds memory limit per test 256 megabytes input sta...

Codeforces Round #352 (Div. 2) C. Recycling Bottles __ geometry, greedy and pretreat

geometry, greedy and pretreat. First of all, the distant will be sigma{ 2*distan of Bottle to the ...

Codeforces Round #352 (Div. 2) C. Recycling Bottles

C. Recycling Bottles time limit per test 2 seconds memory limit per test 256 megabytes ...

Codeforces Round #352 (Div. 2) C D

Codeforces Round #352 (Div. 2) C. Recycling Bottles 题目链接:点这里!!!! 题意: A、B两个人的任务负责把地图上的n个...

Codeforces Round #352(Div 2)

又一次半夜打CF。(队友太强直接秒题解,然而我座位比较远耳朵不好(雾)听不见)总之,最后结果400多名。估计还能重新上蓝。A题:*题目描述: 请你求这样的序列“1234567891011……”的第n...

Codeforces Round #352 (Div. 2) D 二分贪心两头 + 细节

Problem: Analyse: - 好的思维就是把左右端点分开来考虑. - 显然对左端点和右端点,都来二分答案贪心判断的求解,找到k步操作它们各自能到达的位置. - 有一个细节就是k很大的...

Codeforces Round #352 (Div. 2) (A-E)

672A Summer Camp题意:1-n数字连成一个字符串, 给定n , 输出字符串的第n个字符。n 很小, 可以直接暴力。 Code:#include using namespace std...
  • Aoxuets
  • Aoxuets
  • 2016年05月14日 02:43
  • 353

Codeforces Round #352 (Div. 2) B. Different is Good __ substrings water problem

the smallest Substring of the given string can be lowercase English letters, so if it is possible to...

解题报告:Codeforces Round #352 (Div. 2)

A.Summer Camp 题意:123456789101112```数字的字符串,询问第n个字符是什么(0 思路:文件输出字符串存进数组 #include #include #include...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Codeforces Round #352 (Div. 2)(A)模拟
举报原因:
原因补充:

(最多只允许输入30个字)