小蓝与钥匙(错排)

https://www.lanqiao.cn/problems/2167/learning/?subject_code=2&group_code=5&match_num=13&match_flow=2&origin=cup

 

 1 import java.util.Scanner;
 2 // 1:无需package
 3 // 2: 类名必须Main, 不可修改
 4 
 5 public class 小蓝选钥匙 {
 6     public static void main(String[] args) {
 7         Scanner sc = new Scanner(System.in);
 8         long a =14;
 9         long n1 = 28;
10         long m = 14;
11         System.out.println(C(n1,m)*D(a));
12 
13     }//全错排列 错位的14把
14     static long D(long a){
15       if(a==0||a==1){
16         return 0;
17       }
18       else if(a==2){
19         return 1;
20       }
21       else{
22         return (a-1)*(D(a-2)+D(a-1));
23       }
24     }
25     //组合C 14 28
26     static long C(long n,long m){
27       long res = 1L;
28       for(int i = 0;i<m;i++){
29        res = res*(n-i)/(i+1);
30       }
31       return res;
32     }
33 }

 

热门相关:美女总裁之贴身高手   甜蜜婚令:首长的影后娇妻   异界之极品奶爸   大唐杨国舅   学霸,你女朋友掉了