codeforces 672A A. Summer Camp(水题)
题目链接:
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.
题意:
问自然数组成的字符串的第n位的数是多少;
思路:
n<=1000,所以直接暴力跑一波;
AC代码:
#include <bits/stdc++.h>
/*#include <iostream>
#include <queue>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdio>
*/
using namespace std;
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
const LL mod=1e9+;
const double PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const int N=2e4+; int n;
int main()
{ scanf("%d",&n);
int cnt=;
for(int i=;i<=;i++)
{
int temp=i,ans=,num=;
while(temp)
{
ans=ans*+temp%;
temp/=;
num++;
}
int s;
while(num--)
{
s=ans%;
ans/=;
cnt++;
if(cnt>=n)
{
cout<<s<<"\n";
return ;
} }
} return ;
}
codeforces 672A A. Summer Camp(水题)的更多相关文章
- codeforces 577B B. Modulo Sum(水题)
题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...
- codeforces 696A Lorenzo Von Matterhorn 水题
这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...
- CodeForces 589I Lottery (暴力,水题)
题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...
- Codeforces Gym 100286G Giant Screen 水题
Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...
- codeforces 710A A. King Moves(水题)
题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...
- codeforces 659A A. Round House(水题)
题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...
- CodeForces 489B BerSU Ball (水题 双指针)
B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- codeforces 702A A. Maximum Increase(水题)
题目链接: A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input sta ...
随机推荐
- MarsEdit 快速插入代码
<div class="cnblogs_Highlighter"> <pre class="brush:objc;gutter:true;"& ...
- DOM对象之查找标签&属性操作
HTML DOM (文档对象模型) DOM(Document Object Model)是一套对文档的内容进行抽象和概念化的方法. JavaScript对DOM进行了实现,对应于JavaScript中 ...
- mysql workbench 导出建表语句
导出建表语句和数据 server—–>data export—–>选中表 注意,export to dump project folder,这种方式是每个表对应一个sql文件. 导出建 ...
- 关于css虚线
今天遇到几个虚线效果,不能一下子反应过来具体属性. 一.dashed和dotted的区别 首先是dashed和dotted都是指“虚线”,但是两者显示的效果不尽相同. 从字面意思来看, dashed: ...
- Oracle SQL Developer Chanage UI to US Lanaguage
\sqldeveloper-4.1.3.20.78-x64\sqldeveloper\sqldeveloper\bin Add content: AddVMOption -Duser.country= ...
- 使用Python控制1602液晶屏实时显示时间(附PyCharm远程调试)
前言 原创文章,转载引用务必注明链接.水平有限,如有疏漏,欢迎指正. 本文介绍一下UP板的GPIO资源使用,以及一个使用Python演示一个简单的demo. 本文使用Markdown写成,为获得更好的 ...
- 吃我一记咸鱼突刺——使用板载RTC定时开机
前言 原创文章,转载引用务必注明链接.水平有限,欢迎指正. 2016年3月30日 Lemuntu(Base On Jessie) 3.10.37 原载于Lemaker论坛.汇总于此. 看ATC2603 ...
- Android Problem- android.content.res.Resources$NotFoundException: String resource ID #0xa
在使用listview时出现错误android.content.res.Resources$NotFoundException: String resource ID #0xa 经查证是在调用Text ...
- 提高系统性能——对SQL语句优化的思考
软件在研发的过程中自始至终都在留意着系统的可扩展性.但与此同一时候也在关注着系统的性能,SQL语句作为系统性能的一环不容忽视.从今天開始结合开发的经验,谈一下我对SQL语句优化的理解和认知: 1.在联 ...
- c#中的多态 c#中的委托
C#中的多态性 相信大家都对面向对象的三个特征封装.继承.多态很熟悉,每个人都能说上一两句,但是大多数都仅仅是知道这些是什么,不知道CLR内部是如何实现的,所以本篇文章主要说说多态性 ...