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 ...
随机推荐
- windows下使用curl.exe模拟ajax请求
curl 是一般linux发行版中都带有的小工具,利用这个工具可以很方便的下载文件,我一般使用这个工具来查看某个页面相应的HTTP头信息,在Windows系统中我们也一样可以使用这个工具,如果不需要支 ...
- 《算法》第四版 IDEA 运行环境的搭建
<算法>第四版 IDEA 运行环境的搭建 新建 模板 小书匠 在搭建之初,我是想不到会出现如此之多的问题.我看了网上的大部分教程,都是基于Eclipse搭建的,还没有使用IDEA搭建的教程 ...
- C++ 基础 引用
1.引用的本质 int b = 10; int &a = b; 等效于: int * const a = &b; 由于 a 是 const声明,所以一旦定义无法修改,所以要在定义时就要 ...
- Leetcode 337. 打家劫舍 III
题目链接 https://leetcode.com/problems/house-robber-iii/description/ 题目描述 在上次打劫完一条街道之后和一圈房屋后,小偷又发现了一个新的可 ...
- 20145202马超 《Java程序设计》第三周学习总结
************************http://git.oschina.net/tuolemi/java这是git的那个网址********************* 函数的重载:在同一 ...
- python sys模块和序列化模块
sys模块是与python解释器交互的一个接口: sys.argv 命令行参数List,第一个元素是程序本身路径 sys.exit(n) 退出程序,正常退出时exit(0),错误退出sys.exit( ...
- Altium Designer多原理图、PCB更新处理
问题扫述: 一般一个同程有多个原理图.PCB.但是AD默认从原理图更新到PCB会把全部原理图都更新过去.因此需要稍加设置. 一.
- TCP close seq问题
测试mt_hls一条流时,发现会话的时长总是对应不上. 仔细观察发现: 注意 1.包1735 (客户端) 发送FIN 请求,seq = 2435582428 2.包1736,1737,1738 (服务 ...
- web开发学习之路是否有尽头
Linux/Git/Pip/Npm/Composer Apache/Ngnix Mysql/MongoDb/Redis PHP/Python/NodeJS javascript/jQuery/Expr ...
- 【HTML&CSS】 第二章:标准模式下的页面与怪异模式下的页面区别
盒模型 前面提到,盒模型(box mode)是浏览器 Quirks Mode 和 Standards Mode 的主要区别. 描述 对于“盒模型”一词并没有明确的文档定义,它是开发人员描述 CSS 中 ...