leetcode 400
来源:互联网 发布:单片机排针怎么用 编辑:程序博客网 时间:2024/05/02 15:04
水题,照着模拟即可
但容易写错,在 pow(10,cnt) 上忘记向上取整wa了几发
class Solution {public: int findNthDigit(int n) { int cnt = 1; long long int nub = 9; while( n > nub*cnt ){ n -= cnt*nub; cnt++; nub *= 10; } int pos = ceil(pow(10,cnt-1)); pos += n/cnt ; n = n%cnt; if( n == 0 )pos--,n = cnt; int t = cnt - n; while( pos ){ int x = pos%10; if( t == 0 )return x; t--; pos/=10; } return pos; }};
阅读全文
0 0
- Leetcode 400
- leetcode 400
- LeetCode 400 Nth Digit
- Leetcode 400 Nth Digit
- Leetcode 400(Java)
- Leetcode 400 Nth Digit
- leetcode
- [leetcode]
- LeetCode
- leetcode
- leetcode
- leetcode:
- leetcode:
- LeetCode
- leetcode
- LEETCODE
- leetcode
- leetCode
- Zookeeper
- 服务器端无法找到或加载[medicalPackageService]
- 4.21 leetcode -21 regular-expression-matching
- 让人流口水!当苹果 ARKit 与点餐应用结合在一起
- linux C中的select的使用
- leetcode 400
- 事件冒泡与事件捕获,附实例
- Codeforces-813D Two Melodies(dp)
- VS Code “Cannot validate the php file. The php program was not found”解决办法
- win7 系统安装图解教程
- Excel 快速输入各类数据的方法技巧示例总结
- 接口的幂等性
- View[5] ViewTreeObserver
- 基于angular.js发送ajax请求实现前后台数据交互