题目链接:

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
  1. 3
output
  1. 3
input
  1. 11
output
  1. 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.

题意:

问自然数组成的字符串的第n位的数是多少;

思路:

n<=1000,所以直接暴力跑一波;

AC代码:

  1. #include <bits/stdc++.h>
  2. /*#include <iostream>
  3. #include <queue>
  4. #include <cmath>
  5. #include <cstring>
  6. #include <algorithm>
  7. #include <cstdio>
  8. */
  9. using namespace std;
  10. #define Riep(n) for(int i=1;i<=n;i++)
  11. #define Riop(n) for(int i=0;i<n;i++)
  12. #define Rjep(n) for(int j=1;j<=n;j++)
  13. #define Rjop(n) for(int j=0;j<n;j++)
  14. #define mst(ss,b) memset(ss,b,sizeof(ss));
  15. typedef long long LL;
  16. const LL mod=1e9+;
  17. const double PI=acos(-1.0);
  18. const int inf=0x3f3f3f3f;
  19. const int N=2e4+;
  20.  
  21. int n;
  22. int main()
  23. {
  24.  
  25. scanf("%d",&n);
  26. int cnt=;
  27. for(int i=;i<=;i++)
  28. {
  29. int temp=i,ans=,num=;
  30. while(temp)
  31. {
  32. ans=ans*+temp%;
  33. temp/=;
  34. num++;
  35. }
  36. int s;
  37. while(num--)
  38. {
  39. s=ans%;
  40. ans/=;
  41. cnt++;
  42. if(cnt>=n)
  43. {
  44. cout<<s<<"\n";
  45. return ;
  46. }
  47.  
  48. }
  49. }
  50.  
  51. return ;
  52. }

codeforces 672A A. Summer Camp(水题)的更多相关文章

  1. codeforces 577B B. Modulo Sum(水题)

    题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树

    A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...

  3. codeforces 696A Lorenzo Von Matterhorn 水题

    这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...

  4. CodeForces 589I Lottery (暴力,水题)

    题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...

  5. Codeforces Gym 100286G Giant Screen 水题

    Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...

  6. codeforces 710A A. King Moves(水题)

    题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...

  7. codeforces 659A A. Round House(水题)

    题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...

  8. CodeForces 489B BerSU Ball (水题 双指针)

    B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  9. codeforces 702A A. Maximum Increase(水题)

    题目链接: A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input sta ...

随机推荐

  1. iOS 设置RGB色的宏

    转自:http://lizhuang.iteye.com/blog/1931768 
//RGB Color macro #define UIColorFromRGB(rgbValue) [UICol ...

  2. Laravel 5.1 报错:[App\Http\Requests\Request] is not instantiable

    Laravel 5.1 报错:[App\Http\Requests\Request] is not instantiable 错误提示: Whoops, looks like something we ...

  3. Centos7安装遇到的问题及详解

    1.虚拟机中选择的是NAT模式,我的笔记本电脑是拨号上网,用桥接模式,找不到网卡,在windows的dos界面用ipconfig查看的结果 PPP适配器 宽带连接:IPv4 地址 . . . . . ...

  4. delphi 与 sqlite3

      delphi与sqlite file:0 前言 本文的目的在于采用流水账方式来记录学习delphi访问嵌入式数据库sqlite中的一些点滴.欢迎各位同好共同学习和批评指正. file:1 准备工作 ...

  5. for 循环进化史

    ECMAScript 6已经逐渐普及,经过二十多年的改进,很多功能也有了更成熟的语句,比如 for 循环 这篇博客将介绍一下从最初的 for 循环,到 ES6 的 for-of 等四种遍历方法 先定义 ...

  6. 关于克隆gitlab项目的一些 问题列表

    1. gitLab项目clone过后, 运行ng serve出错: 解决方式: npm install -g node-gyp npm install --global --production wi ...

  7. ASP.NET Core 依赖注入(构造函数注入,属性注入等)

    原文:ASP.NET Core 依赖注入(构造函数注入,属性注入等) 如果你不熟悉ASP.NET Core依赖注入,先阅读文章: 在ASP.NET Core中使用依赖注入   构造函数注入 构造函数注 ...

  8. [转]Linux统计代码行数

    wc -l *.c *.h 就可以知道当前目录下的所有c 和 h 文件的行数的详细信息.很不错 如果要递归,可以配合其他命令一起使用 当前目录及子目录: find . -name *.c |xargs ...

  9. cocos2d-x改底层之获取UIListView的实际内容大小

    实际项目中UI界面中常常会用到UIListView.大多会在CocoStudio中直接加入这个控件. 可是在使用中发现了一些坑和功能缺乏,然后就看了一下底层的逻辑,发现略微改一下底层就能够满足需求,所 ...

  10. 【转载】细聊分布式ID生成方法

    一.需求缘起 几乎所有的业务系统,都有生成一个记录标识的需求,例如: (1)消息标识:message-id (2)订单标识:order-id (3)帖子标识:tiezi-id 这个记录标识往往就是数据 ...