https://leetcode.com/problems/count-numbers-with-unique-digits/

给定一个n,计算[0,10^n]中十进制中每一位都不相同的数的数目。

class Solution{
public:
int countNumbersWithUniqueDigits(int n){
int res=;
int wei = min(, n);
for(int i=wei; i>; i--){
int tmp = ;
for(int j=i-; j>; j--)
tmp *= -i+j+;
res+=tmp;
}
return res+;
}
};

leetcode_357. Count Numbers with Unique Digits的更多相关文章

  1. LC 357. Count Numbers with Unique Digits

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  2. [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  3. Count Numbers with Unique Digits

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  4. Leetcode: Count Numbers with Unique Digits

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  5. 357. Count Numbers with Unique Digits

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  6. 【Leetcode】357. Count Numbers with Unique Digits

    题目描述: Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. ...

  7. [Swift]LeetCode357. 计算各个位数不同的数字个数 | Count Numbers with Unique Digits

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  8. Java [Leetcode 357]Count Numbers with Unique Digits

    题目描述: Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. ...

  9. Count Numbers with Unique Digits -- LeetCode

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10^n. Exam ...

随机推荐

  1. Adding Security to an Existing Website

    The procedure earlier in this article relies on using the Starter Site template as the basis for web ...

  2. Linux内核--基于Netfilter的内核级包过滤防火墙实现

    测试内核版本:Linux Kernel 2.6.35----Linux Kernel 3.2.1 原创作品,转载请标明http://blog.csdn.net/yming0221/article/de ...

  3. openfire源码编译后部署到linux

    1.源码通过编号后,会生成target目录,直接把target目录拷贝到linux下即可: 2.启动openfire: ./openfire.sh start 3.退出直接ctr + c 问题:如果一 ...

  4. 整型变量修饰符,char类型数据存储原理,字节数,

    //------------------整型变量修饰符 修饰符(int short long longlong signed unsigned)所有修饰符都是用来修整形 int 4short %hd ...

  5. BZOJ_4184_shallot_线段树按时间分治维护线性基

    BZOJ_4184_shallot_线段树按时间分治维护线性基 Description 小苗去市场上买了一捆小葱苗,她突然一时兴起,于是她在每颗小葱苗上写上一个数字,然后把小葱叫过来玩游戏. 每个时刻 ...

  6. 【ZJOI 2006】 物流运输

    [题目链接] 点击打开链接 [算法] 令cost(i,j) = 第i天到第j天走相同的路线,路线长度的最小值 那么,只需筛选出第i天到第j天可以装卸货物的码头,然后将这些码头之间连边,跑弗洛伊德(或其 ...

  7. vs 中switch语句快捷键列出枚举

    先switch然后两下tab会补完到default,光标显示在switch后的变量这时输入枚举,输完后回车,自动补完所有枚举的case

  8. bzoj 4826: [Hnoi2017]影魔【单调栈+树状数组+扫描线】

    参考:https://www.cnblogs.com/lcf-2000/p/6789680.html 这是一个相对码量少的做法,用到了区间修改区间查询的树状数组,详见:www.cnblogs.com/ ...

  9. Linux之旅第一篇-目录结构及操作目录

    一.引言 Linux对java开发来说也是一项必备的技能,因为项目基本都是部署在Linux操作系统的服务器中,虽然项目不一定需要我们去部署,但不管是自己测试环境部署,还是一些生产环境中日志的查看,Li ...

  10. python之排序算法-冒泡、选排、快排

    影响内排序算法性能的三个因素: 时间复杂度:即时间性能,高效率的排序算法应该是具有尽可能少的关键字比较次数和记录的移动次数 空间复杂度:主要是执行算法所需要的辅助空间,越少越好. 算法复杂性.主要是指 ...