public class Solve{public static void main(String[] args){int aa=minRoot(4,10,13);int bb=minRoot(4,aa,15);System.out.println(bb);}public static int minRoot(int K,int a,int b){if(a<b){int tmp=a;a=b;b=tmp;}if (a > Math.pow(2, K) - 1 || b < 0)return -1;if (a >= Math.pow(2, K - 1) && b <= Math.pow(2, K - 1)) {return (int) Math.pow(2, K - 1);}if (b > Math.pow(2, K - 1)) {return (int)(Math.pow(2, K - 1)+minRoot(K-1,(int)(a-Math.pow(2, K - 1)),(int)(b-Math.pow(2, K - 1))));}return minRoot(K-1,a,b);}}
求二叉排序树的最小根
最新推荐文章于 2022-12-14 02:35:43 发布