Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
873 B
3
Indexable
Never
import java.util.*;
public class HelloWorld{
    
    static List<String> al = new ArrayList<>();

     public static void main(String []args){
        int[] arr = new int[] { 4, 1 };
        int n = 2;
        int res = special_numbers(n, arr);
        System.out.println(res);
     }
     
     static int special_numbers(int n, int[] arr) {
         int result = 0;
         for (int x : arr) {
             result += nonDecNums(x);
         }
         return result;
     }
     
     static int nonDecNums(int n) 
    { 
        int[][] a = new int[n + 1][10]; 
  
        for (int i = 0; i <= 9; i++) 
            a[0][i] = 1; 
  
        for (int i = 1; i <= n; i++) 
            a[i][9] = 1; 
  
        for (int i = 1; i <= n; i++) 
            for (int j = 8; j >= 0; j--) 
                a[i][j] = a[i - 1][j] + a[i][j + 1]; 
  
        return a[n][0]; 
    }
}