leetcode_357. Count Numbers with Unique Digits
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的更多相关文章
- 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 ...
- [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...
- Count Numbers with Unique Digits
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...
- Leetcode: Count Numbers with Unique Digits
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...
- 357. Count Numbers with Unique Digits
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...
- 【Leetcode】357. Count Numbers with Unique Digits
题目描述: Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. ...
- [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 ...
- 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. ...
- 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 ...
随机推荐
- JDBC+XML+DOM4J
利用xml文件封装数据库配置信息xml文件放在src目录下/testjdbc1/src/DBUtil.xml <?xml version="1.0" encoding=&qu ...
- HDU4027 Can you answer these queries? —— 线段树 区间修改
题目链接:https://vjudge.net/problem/HDU-4027 A lot of battleships of evil are arranged in a line before ...
- openssl动态库编译
通常Linux系统自带OpenSSL,但是其so文件由于没有debug信息,因此无法跟踪内部函数,对于学习 不太方便,需要通过源码重新安装. 我的Linux系统是CentOS7,自带的 ...
- html5--js函数在canvas中的应用
html5--js函数在canvas中的应用 总结: 1.script中的函数写了要调用 2.rgb()这样的模式的色彩比较适合做变量 3.body的onload事件 4.带参函数 效果: 代码: & ...
- Ubuntu 12.04 设置终端字体为文泉驿(转载)
转自:http://my.oschina.net/uniquejava/blog/98480 0.说明 在gnome-terminal终端中看习惯了文泉驿微米黑字体,没想到从11.10升级到 ...
- hdu 1348【凸包模板】
#include<iostream> #include<iostream> #include<algorithm> #include<cmath> us ...
- [Swift]扩展String类:实现find()查找子字符串在父字符串中的位置
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- shiro之SimpleAccountRealm
我使用的是maven构建的工程,junit测试 Shiro认证过程 创建SecurityManager--->主体提交认证--->SecurityManager认证--->Authe ...
- javascript 截取url参数
var url="http://127.0.0.1:8080/photo/list.jsp?page=2&user=hongchen"; var params_arr = ...
- Linux下VIM配置以及常用快捷键
一.VIM配置 在目录 /etc/vim下面,有个名为vimrc的文件,这是系统中公共的vim设置文件,对所有用户都有效.而在每个用户的主目录下,都能自己建立私有的设置文件,命名为:“.vimrc”. ...