int Top_Down_Rod(int p[],int n){ int r=0; int i; if(n==0)return 0; for (i=1;i<=n;i++){ int tmp=p[i]+Top_Down_Rod(p,n-i); count=count+1; System.out.println("第"+count+"次"+(n)); r=(r>=tmp)?r:tmp; } return r; }
T(n)=T(n-1)+...T(0);
T(n)=2的n次方减一
2024-03-24 20:47:16
int Top_Down_Rod(int p[],int n){ int r=0; int i; if(n==0)return 0; for (i=1;i<=n;i++){ int tmp=p[i]+Top_Down_Rod(p,n-i); count=count+1; System.out.println("第"+count+"次"+(n)); r=(r>=tmp)?r:tmp; } return r; }
T(n)=T(n-1)+...T(0);
T(n)=2的n次方减一