https://leetcode.com/problems/nth-digit/

public class Solution {
public int findNthDigit(int n) {
int k = 9;
int b = 1;
// 需要加上对b的限制
while (b < 9 && n > k*b) {
n -= k * b;
k *= 10;
b ++;
}
int rank = (n - 1) / b;
int app = (n - 1) % b;
int num = (int)Math.pow(10, b-1) + rank;
for (int i=b-1; i>app; i--) {
num /= 10;
}
return num % 10;
}
}

nth-digit的更多相关文章

  1. [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 ...

  2. 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 ...

  3. hdu 1597 find the nth digit

    find the nth digit Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  4. 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 ...

  5. find the nth digit(二分查找)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1597 find the nth digit Time Limit: 1000/1000 MS (Jav ...

  6. [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 ...

  7. C++版 - Leetcode 400. Nth Digit解题报告

    leetcode 400. Nth Digit 在线提交网址: https://leetcode.com/problems/nth-digit/ Total Accepted: 4356 Total ...

  8. (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 ...

  9. LeetCode——Nth Digit

    Question Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... ...

  10. hdu 1597 find the nth digit (数学)

    find the nth digit Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

随机推荐

  1. CSU - 2062 Z‘s Array

    Description Z likes to play with array. One day his teacher gave him an array of n elements, and ask ...

  2. JAVAEE——宜立方商城07:Linux上搭建Solr服务、数据库导入索引库、搜索功能的实现

    1. 学习计划 1.Solr服务搭建 2.Solrj使用测试 3.把数据库中的数据导入索引库 4.搜索功能的实现 2. Solr服务搭建 2.1. Solr的环境 Solr是java开发. 需要安装j ...

  3. 常用的Jquery工具方法

    一.根据后端动态字段,如何把驻点输出在页面上?1.可以提前写好css,设置li的宽度,在页面中通过模板引擎语法动态加载不同的className.2.可以根据驻点个数和位置,用jquery去动态计算赋值 ...

  4. leetcode 算法 Excel表列序号 python实现

    这道题给我感觉就像一个26进制数一样. A 就是1 B是2 .... Z 是26 如果AB 两位,那就是  1 * 26 + 2   就是A 的数值*26 + B的数值 如果是MNP 三位数   那就 ...

  5. python opencv3 视频文件的读写

    git: https://github.com/linyi0604/Computer-Vision # coding:utf8 import cv2 """ 读取视频文件 ...

  6. 机器学习之路:python 特征降维 主成分分析 PCA

    主成分分析: 降低特征维度的方法. 不会抛弃某一列特征, 而是利用线性代数的计算,将某一维度特征投影到其他维度上去, 尽量小的损失被投影的维度特征 api使用: estimator = PCA(n_c ...

  7. MVC 设计模式与三层架构

    一.JavaEE开发模式 什么是开发模式 模式是在开发过程中总结出的"套路",总结出的一套约定俗成的设计模式 JavaEE模式 model1模式 技术组成 :jsp+javaBea ...

  8. [BZOJ4372]烁烁的游戏(动态点分治+线段树)

    和[BZOJ3730]震波几乎一样,每个点建两棵线段树分别代表它的管辖范围内以它为LCA的路径的贡献和它对父亲的贡献. 注意点分树上的点的距离在原树上不单调,所以不能有若距离超出限制就break之类的 ...

  9. bzoj 5210(树链刨分下做个dp)

    5210: 最大连通子块和 Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 211  Solved: 65[Submit][Status][Discus ...

  10. 【推导】Codeforces Round #472 (rated, Div. 2, based on VK Cup 2018 Round 2) B. Mystical Mosaic

    题意:给你一个棋盘的最终局面. 你的一次操作可以选择一些行和列,将它们的交叉点染黑,不能重复选择某行或者某列.问你是否能经过数次操作之后,达到目标局面. 就枚举所有黑点,如果该点行列都没被标记,就给它 ...