find the nth digit
S1 = 1
S2 = 12
S3 = 123
S4 =
1234
.........
S9 = 123456789
S10 = 1234567891
S11 =
12345678912
............
S18 =
123456789123456789
..................
现在我们把所有的串连接起来
S =
1121231234.......123456789123456789112345678912.........
那么你能告诉我在S串中的第N个数字是多少吗?
接下来的K行每行有一个整数N(1 <= N <
2^31)。
#include <stdio.h>
int main(){
int T;
int number;
int i;
scanf("%d",&T);
while(T--){
scanf("%d",&number);
i=;
while(){
if(number>i){
number-=i;
i++;
}
else
break;
}
number%=;
if(number==)
number=;
printf("%d\n",number);
}
return ;
}
find the nth digit的更多相关文章
- [LeetCode] Nth Digit 第N位
Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note: n i ...
- Leetcode: Nth Digit
Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note: n i ...
- hdu 1597 find the nth digit
find the nth digit Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- Nth Digit | leetcode
Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note: n i ...
- find the nth digit(二分查找)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1597 find the nth digit Time Limit: 1000/1000 MS (Jav ...
- [Swift]LeetCode400. 第N个数字 | Nth Digit
Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note:n is ...
- C++版 - Leetcode 400. Nth Digit解题报告
leetcode 400. Nth Digit 在线提交网址: https://leetcode.com/problems/nth-digit/ Total Accepted: 4356 Total ...
- (lower_bound)find the nth digit hdu1597
find the nth digit Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- LeetCode——Nth Digit
Question Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... ...
- hdu 1597 find the nth digit (数学)
find the nth digit Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
随机推荐
- ASP.NET自定义控件入门Demo
最近看了MSDN关于自定义控件的介绍,根据官方的文档,自己学着做了一个简单的Demo给需要的朋友参考. ASP.NET 源生的TextBox是不带Label标签的,这里我要实现的是创建一个带Label ...
- socket对于大数据的发送和接收
大数据是指大于32K或者64K的数据. 大数据的发送和接收通过TSTREAM对象来进行是非常方便的. 我们把大数据分割成一个个4K大小的小包,然后再依次传输. 一.大数据的发送的类语言描述: 1)创建 ...
- oradmin相关用法
[转]oradmin相关用法 创建例程: -NEW -SID sid | -SRVC 服务 [-INTPWD 口令] [-MAXUSERS 数量] [-STARTMODE a|m] [-PFILE 文 ...
- poj1061 青蛙的约会 扩展欧几里德的应用
这个题解得改一下,开始接触数论,这道题目一开始是看了别人的思路做的,后来我又继续以这种方法去做题,发现很困难,学长告诉我先看书,把各种词的定义看懂了,再好好学习,我做了几道朴素的欧几里德,尽管是小学生 ...
- hdoj 5358 First One
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5358 一开始一直以为是一道数学题,在找有什么规律化简Log2(S(i,j)),结束了以后才造 ⌊lo ...
- 使用IBatisNet的网站,修改database.config无效的问题解决
这周五去客户那更新了一个使用了IBatisNet的Web项目,备份了项目.数据库之后,替换更新的文件(含bin目录)却报数据库连接错. 因为是接手的一个维护项目,加上交接有点问题,所以遇到问题只能自己 ...
- 一个python
#!/usr/bin/env python #coding=utf-8 import os # 遍历文件 r=input("type a directory name:") for ...
- Flex data
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ht ...
- 有关获取session属性时报nullPointException(空指针异常)的解决方案
一般我们在从session中获取数据时,需要先进行赋值,也就是必须先进行session.setAttribute(String,Object)方法进行赋值,然后我们才能从session中获取内容,但是 ...
- pycharm快捷键大全
Python IDE PyCharm的快捷键大全1.编辑(Editing)Ctrl + Space 基本的代码完成(类.方法.属性)Ctrl + Alt + Space 快速导入任意类Ctrl + S ...