Codeforces Round #352 (Div. 2) A
1 second
256 megabytes
standard input
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.
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.
题意:"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15...". 连续的数 组成一个字符串(无空格 ,只是便于理解) 请输出n位置上的字符
题解: 可以直接暴力!!! 比赛的时候想多了 分析出 1~99 共189位 最多为一个三位数 分段分析 注意细节
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
#include<queue>
#include<stack>
#define ll __int64
#define pi acos(-1.0)
using namespace std;
int n;
int main()
{
scanf("%d",&n);
if(n<=)
{
cout<<n<<endl;
return ;
}
if(n>&&n<=)
{
n=n-;
int exm=n/;
n--;
n=n%;
if(n==)
cout<<(exm+)%<<endl;
else
cout<<(exm+)/<<endl;
return ;
}
if(n>)
{
n=n-;
int exm=n/;
n=n-;
n=n%;
if(n==)
cout<<(exm+)%<<endl;
if(n==)
cout<<(exm+)/<<endl;
if(n==)
cout<<(exm+-(exm+)/*)/<<endl;
return ;
}
return ;
}
Codeforces Round #352 (Div. 2) A的更多相关文章
- Codeforces Round #352 (Div. 2) C. Recycling Bottles 暴力+贪心
题目链接: http://codeforces.com/contest/672/problem/C 题意: 公园里有两个人一个垃圾桶和n个瓶子,现在这两个人需要把所有的瓶子扔进垃圾桶,给出人,垃圾桶, ...
- Codeforces Round #352 (Div. 2) D. Robin Hood
题目链接: http://codeforces.com/contest/672/problem/D 题意: 给你一个数组,每次操作,最大数减一,最小数加一,如果最大数减一之后比最小数加一之后要小,则取 ...
- Codeforces Round #352 (Div. 2) D. Robin Hood (二分答案)
题目链接:http://codeforces.com/contest/672/problem/D 有n个人,k个操作,每个人有a[i]个物品,每次操作把最富的人那里拿一个物品给最穷的人,问你最后贫富差 ...
- Codeforces Round #352 (Div. 1) B. Robin Hood 二分
B. Robin Hood 题目连接: http://www.codeforces.com/contest/671/problem/B Description We all know the impr ...
- Codeforces Round #352 (Div. 1) A. Recycling Bottles 暴力
A. Recycling Bottles 题目连接: http://www.codeforces.com/contest/671/problem/A Description It was recycl ...
- Codeforces Round #352 (Div. 2) B. Different is Good 水题
B. Different is Good 题目连接: http://www.codeforces.com/contest/672/problem/B Description A wise man to ...
- Codeforces Round #352 (Div. 2) A. Summer Camp 水题
A. Summer Camp 题目连接: http://www.codeforces.com/contest/672/problem/A Description Every year, hundred ...
- Codeforces Round #352 (Div. 2) ABCD
Problems # Name A Summer Camp standard input/output 1 s, 256 MB x3197 B Different is Good ...
- Codeforces Round #352 (Div. 2)
模拟 A - Summer Camp #include <bits/stdc++.h> int a[1100]; int b[100]; int len; void init() { in ...
- Codeforces Round #352 (Div. 2) B - Different is Good
A wise man told Kerem "Different is good" once, so Kerem wants all things in his life to b ...
随机推荐
- pip安装第三方包总失败
第一步:升级pip python -m pip install -U pip 第二布:安装想下载的第三方包 python -m pip install xx 一般来说pip安装不会失败的,失败的话就尝 ...
- LeetCode970. 强整数
问题:970. 强整数 用户通过次数0 用户尝试次数0 通过次数0 提交次数0 题目难度Easy 给定两个非负整数 x 和 y,如果某一整数等于 x^i + y^j,其中整数 i >= 0 且 ...
- Python学习之三级菜单
Python经典练习题 - 三级菜单 需求: 可依次选择进入各子菜单 可从任意一层往回退到上一层 可从任意一层退出程序 示例代码: # -*- coding: utf-8 -*- menu = { ' ...
- js面向(基于)对象编程—类(原型对象)与对象
JS分三个部分: 1. ECMAScript标准--基础语法 2. DOM Document Object Model 文档对象模型 3. BOM Browser Object Moldel 浏览 ...
- thinkphp5控制器向+vue的data里传值
传一维数组传值 $array=['id'=>40,"cat_name"=>"明星产品"]; $MenuCats_info=json_encode($ ...
- python中的字符串内置方法小结
#!/usr/local/bin/python3 # -*- coding:utf-8 -*- ''' name="my wife is mahongyan" ---------- ...
- linux最大进程数
使用 ulimit -a 命令,查看 max user processes 的输出,就是系统最大进程数 core file size (blocks, -c) unlimited data seg s ...
- HTML5技巧
HTML5技巧 HTML5 技巧一:当今科技发展的速度真惊人,稍不留神,就可能无法跟上它的步伐.新一代的HTML-HTML5的发展也不停的带给我们新的惊喜,我们将通过这篇文章向大家介绍一些HTML ...
- 《Cracking the Coding Interview》——第14章:Java——题目2
2014-04-26 18:44 题目:在java的try-catch-finally语句块里,如果catch里面有return语句的话,finally还会被执行吗? 解法:会. 代码: // 14. ...
- 基于mysqldump备份集来恢复某个误操作的表(drop,truncate)
Preface How to rescue a dropped or truncated table online?Dropping or truncating is ddl oper ...