public long query(long x,long y,long nums[][]) { if(x<3 && y<3) { return nums[(int) (x-1)][(int)(y-1)]; } else { int i=0,j=0; long temp=x-1; while(temp>0) { i++; temp=temp/2; } temp = y-1; while(temp>0) { j++; temp=temp/2; } if(i==j) { i--; j--; return query((long)(x-Math.pow(2, i)),(long)(y-Math.pow(2, j)),nums)+nums[1][1]; }else if(i>j) { i--; return query((long)(x-Math.pow(2, i)),y,nums)+nums[1][0]; }else { j--; return query(x,(long)(y-Math.pow(2, j)),nums)+nums[0][1]; } } } 因为那个两个WHILE RUNOUT了 = = 本来应该可以过的 忘记log2怎么用math写了