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 ...
随机推荐
- 解决Cannot reinitialise DataTable问题 解决dataTables再次调用不能清空数据
这里我们只需要多设置一个字段 “destroy" : true 即可 或者设置retrieve: true, 或者在加载datatable之前使用$("#example" ...
- Session的生命同期
一.什么是Session,怎么用 Session是存放用户与web服务器之间的会话,即服务器为浏览器开辟的存储空间. 由于浏览器与服务器之间的会话是无状态(无状态的意思是会话之间无关联性,无法识别该用 ...
- VM12虚拟机安装os x 10.11系统以及注意事项
一.安装步骤 原文链接:https://blog.csdn.net/soachenshui/article/details/49251513 https://blog.csdn.net/soachen ...
- 谷歌浏览器如何调试JS
平常在开发过程中,经常会接触到前端页面.那么对于js的调试那可是家常便饭,谷歌浏览器是常用来调试JS代码的工具,本文主要介绍如何利用谷歌浏览器来调试JS代码,协助我们进行开发工作,加快开发效率. 1. ...
- 636. Exclusive Time of Functions
// TODO: need improve!!! class Log { public: int id; bool start; int timestamp; int comp; // compasa ...
- 2286: [Sdoi2011]消耗战
2286: [Sdoi2011]消耗战 链接 分析 虚树练习题. 构建虚树,在虚树上DP. 跟着gxb学虚-tree... 代码 #include <cstdio> #include &l ...
- 4525: [Cerc2012]Kingdoms
4525: [Cerc2012]Kingdoms 题意 n个国家,两两之间可能存在欠债或者被欠债的关系,一个国家破产:其支出大于收入.问一个国家能否坚持到最后. 思路 很有意思的一道题. dp[s]表 ...
- python里面list()函数
1. list() 方法用于将元组转换为列表. 元组与列表是非常类似的,区别在于元组的元素值不能修改,元组是放在括号中,列表是放于方括号中. 2. python里面的变量不用提前声明.
- 《Cracking the Coding Interview》——第9章:递归和动态规划——题目7
2014-03-20 03:35 题目:实现画图的Flood Fill操作. 解法:DFS和BFS皆可,但BFS使用的队列在时间复杂度上常数项比较大,速度略慢,所以我选了DFS.当然,如果图很大的话D ...
- Lazarus教程 中文版后续给出
市面上有介绍Delphi的书籍(近来Delphi的书也是越来越少了),但没有一本系统的介绍Lazarus的书,这本书是网上的仅有的一本Lazarus教程,目前全部是英文,不过我已经着手开始翻译,争取尽 ...