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. 每天进步一点点—mysql-mysqldump

    一.        简单介绍 mysqldump是client用来备份数据库或者在不通数据库之间进行数据迁移的工具,备份内容包括创建表或者装载表的SQL语句 二.       命令格式   备份单个数 ...

  2. beego07----web博客

    conf/app.conf appname = blog1 httpport = 8080 runmode = dev name=admin pwd=admin controllersmy/attac ...

  3. linux下jiffies定时器和hrtimer高精度定时器【转】

    本文转载自:http://blog.csdn.net/dosculler/article/details/7932315 一.jiffies定时器,HZ=100,精度只能达到10ms. 注:采用jif ...

  4. bzoj2683(要改一点代码)&&bzoj1176: [Balkan2007]Mokia

    仍然是一道cdq模版.. 那么对于一个询问,容斥一下分成四个,变成问(1,1)~(x,y),那么对于x,y,修改只有x'<=x&&y'<=y,才对询问有影响,那么加上读入顺 ...

  5. svn回到历史的某个版本

    svn回到历史的某个版本 分类: linux大类2011-08-05 10:25 7468人阅读 评论(0) 收藏 举报 svntortoisesvn svn回到历史的某个版本在代码的编写过程中,难免 ...

  6. spring-boot快速搭建解析

    创建方式: 1.在File菜单里面选择 New > Project,然后选择Spring Initializr: 2.使用maven直接构建,添加依赖. 1 2 3 4 pom.xml:Mave ...

  7. BZOJ_3998_[TJOI2015]弦论_后缀自动机

    BZOJ_3998_[TJOI2015]弦论_后缀自动机 Description 对于一个给定长度为N的字符串,求它的第K小子串是什么. Input 第一行是一个仅由小写英文字母构成的字符串S 第二行 ...

  8. yaffs2根文件系统的构建过程

    基于BusyBox-1.19.2  (以其它作者的作为参考) 1. 下载BusyBox的源码 http://busybox.net/ 2. 解压#tar xvzf busybox-1.19.2.tgz ...

  9. java.util.Optional

    public class OptionalDemo { public static void main(String[] args) { //创建Optional实例,也可以通过方法返回值得到. Op ...

  10. Jmeter压测Thrift服务接口

    此文已由作者夏鹏授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. Apache Jmeter是基于Java开发的性能测试工具,支持多种协议的测试,包括:Web(HTTP/HTT ...