现在有"abcdefghijkl”12个字符,将其所有的排列中按字典序排列,给出任意一种排列,说出这个排列在所有的排列中是第几小的? 输入 第一行有一个整数n(0<n<=10000); 随后有n行,每行是一个排列; 样例输入 3 abcdefghijkl hgebkflacdji gfkedhjblcia 输出 输出一个整数m,占一行,m表示排列是第几位; 样例输出 1 302715242 260726926 public class Main { public static long postion (int n){ if(n==1){ return 1; } return n*postion(n-1); } public static long index(char[] p,char c,int inde){ int size=1; for (int i = 0; i < inde; i++) { if(c-p[i]>0){ size++; } } return (c-96)-size; } public static long getSize(char[] p,int index,long size){ char c=p[index]; if(index==p.length-1){ return 1; } long num=index(p, c, index)*postion(12-index-1); return num+getSize(p, ++index, num); } public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); sc.nextLine(); for (int i = 0; i < n; i++) { String str=sc.nextLine(); char [] cc=str.toCharArray(); System.out.println(getSize(cc, 0, 0)); } } }