[ダイナミックプログラミング]ユニークな数字でleetcode 357カウント数

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

1:10

2:10 + 9×9

3:10 + 9×9 + 9×9×8

4:10 + 9×9 + 9×9×8×7

......

クラス解決{
 パブリックINT countNumbersWithUniqueDigits(INT N){
         場合(Nの== 0リターン 1 int型 llast = 1 ;
        int型最後= 10 ;
        以下のためにint型 I = 2 ; iが<= N; iは++ 
        { 
            int型の結果=最後+(最後- llast)*(10 - (I - 1 ))。
            llast = 最後。
            最後 =結果;
        } 
        を返す最後。
    } 
}。

 

おすすめ

転載: www.cnblogs.com/fish1996/p/11332637.html