public class zidian {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "abcdef";
int len1 = str.length();
int len = len1 - 1;
//System.out.println(len);
int num1 = 1, num2 = 1, t = 0,tt=1;
int num = fx(26, len, num1, num2, t);
char[] array=str.toCharArray();
for(int i=0;i<array.length;i++)
System.out.println(array[i]);
for(int i=array.length-1;i>0;i--)
tt=tt*(array[i]-array[i-1]);
System.out.println(num+tt);
}
private static int fx(int j, int len, int num1, int num2, int t) {
for (int i = 0; i < len; i++)
num1 = num1 * (26 - i);
for (int i = 1; i <= len; i++)
num2 = num2 * i;
t = num1/num2 + t;
System.out.println("t:"+t);
if (len > 1) {
len--;
fx(26, len, 1, 1, t);
}
return t;
}
}
算法 字典问题
最新推荐文章于 2021-07-26 20:48:00 发布