您当前的位置: 首页 >  数学

对方正在debug

暂无认证

  • 6浏览

    0关注

    390博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

数字1的个数(思维/数学)

对方正在debug 发布时间:2020-03-14 22:49:51 ,浏览量:6

题目:https://leetcode-cn.com/problems/number-of-digit-one/ 代码:https://leetcode-cn.com/problems/number-of-digit-one/solution/shu-zi-1-de-ge-shu-by-leetcode/ 给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。 思路:计算10进制数每个位上1的贡献个数,代码实现上卡了

class Solution {
public:
    int countDigitOne(int n) {
        int countr = 0;
        for (long long i = 1; i             
关注
打赏
1664076964
查看更多评论
0.3769s