private int upperBound(int x, int arr[]){
        int low = 0;
        int high = arr.length-1;
        while(low <= high){
            int mid = (low+high)/2;
            if(arr[mid] > x && (mid-1 < 0 || arr[mid-1] <= x)){
                return mid;
            }else if(arr[mid] > x){
                high = mid-1;
            }else{
                low = mid+1;
            }
        }
        return -1;
        
    }
http://www.geeksforgeeks.org/find-number-pairs-xy-yx/
src/com/interview/binarysearch/NumberOfPairWithXPowerYGreaterThanYPowerX.java