关闭

CodeForces 672A Summer Camp

266人阅读 评论(0) 收藏 举报
分类:
A. Summer Camp
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.

题意:就是12345678910111213……问你第几位是哪个数。
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int num[1100000];
void init()
{
	int i;
	for(i=1;i<=9;i++)
	{
		num[i]=i;
	}
	int k=10;
	for(i=10;i<=99;i++)
	{
		num[k++]=i/10;
		num[k++]=i%10; 	
	}
	for(i=100;i<=400;i++)
	{
		num[k++]=i/100;
		num[k++]=i/10%10;
		num[k++]=i%100%10;
	}
}
int main()
{
	int n;
	init();
	while(scanf("%d",&n)!=EOF)
	{
		printf("%d\n",num[n]);
	}
	return 0;
}


0
0
查看评论

CodeForces 672A Summer Camp 【sprintf】

Description Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems. This is your first year at summe...
  • Young_12138
  • Young_12138
  • 2017-02-17 23:53
  • 132

codeforces_672A. Summer Camp(string)

A. Summer Camp time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output ...
  • christry_stool
  • christry_stool
  • 2016-05-21 19:54
  • 228

CodeForces 672A Summer Camp(数字游戏,枚举)

http://codeforces.com/problemset/problem/672/A A. Summer Camp time limit per test 1 second memory limit per test 256 mega...
  • shyazhut
  • shyazhut
  • 2016-08-11 17:44
  • 220

CodeForces-672A-Summer Camp

DescriptionEvery year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems.This is your first year at summer ca...
  • Ypopstar
  • Ypopstar
  • 2016-05-20 09:41
  • 352

CodeForces 672A Summer Camp

思路:水题 #include using namespace std; int main() { string s = ""; int i = 1; while(s.size()<1000) { string s1 = ""; ...
  • qq_21057881
  • qq_21057881
  • 2016-05-14 20:37
  • 689

codeforces 672A Summer Camp

点击打开链接 A. Summer Camp time limit per test 1 second memory limit per test 256 megabytes input standard input output standa...
  • zhang__liuchen
  • zhang__liuchen
  • 2017-11-02 20:09
  • 75

CodeForces - 672A Summer Camp (模拟)水

CodeForces - 672A Summer Camp Time Limit:                ...
  • yanghui07216
  • yanghui07216
  • 2016-05-19 22:06
  • 596

【bzoj4103】 【Thu Summer Camp 2015】【异或运算】【可持久化trie】

Description 给定长度为n的数列X={x1,x2,...,xn}和长度为m的数列Y={y1,y2,...,ym},令矩阵A中第i行第j列的值Aij=xi xor  yj,每次询问给定矩形区域i∈[u,d],j∈[l,r],找出第k大的Aij。 Input 第...
  • sunshinezff
  • sunshinezff
  • 2016-05-31 17:03
  • 287

hdu 6045 Is Derek lying?(2017 Multi-University Training Contest - Team 2)

Is Derek lying?Problem DescriptionDerek and Alfia are good friends.Derek is Chinese,and Alfia is Austrian.This summer holiday,they both participate in...
  • blessLZH0108
  • blessLZH0108
  • 2017-07-27 17:39
  • 362

AOJ 2308 —— 计算几何

White Bird Time Limit : 5 sec, Memory Limit : 65536 KB White Bird Angry Birds is a mobile game of a big craze all over the world. You were convi...
  • zkzxmzk
  • zkzxmzk
  • 2013-10-23 15:56
  • 918
    个人资料
    • 访问:173561次
    • 积分:8472
    • 等级:
    • 排名:第2793名
    • 原创:705篇
    • 转载:2篇
    • 译文:0篇
    • 评论:19条
    最新评论