bool isBadVersion(int version);

class Solution {
public:
    int firstBadVersion(int n) {
        int left=1,right=n;
        while(left<right){
            int mid=left+(right-left)/2;
            if(isBadVersion(mid)) right=mid;
            else left=mid+1;
        }
        return left;
    }
};

采用了从左到右逼近的方法,漂亮啊, 逻辑很清楚,又不会出错,nice