标签:public oid iba fun ret rgs 暴力 har string
李白打酒这个用暴力递归很容易算出来,今天想要加上链路记录,原本以为挺简单的事情,却想了很久才想明白,记录一下吧。
public class LibaiDajiu2 {
static char[] c = new char[15];
static int sum = 0;
public static void main(String[] args) {
System.out.println(fun(5,10,2,0));
}
private static int fun(int d , int h, int count, int step) {
if( d ==0 && h ==1 && count == 1 ){
sum ++;
}
if(d> 0){
fun(d-1,h,count*2,step+1);
}
if(h>0){
fun(d,h-1,count-1,step+1);
}
return sum;
}
}
标签:public oid iba fun ret rgs 暴力 har string
原文地址:https://www.cnblogs.com/sansamh/p/9005917.html