Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

疑问?

Posted by gbaoxing at 2012-09-05 20:01:44 on Problem 3863
题目说的是you cannot go below the ground floor也就是说可以到达第0层啊,可是我在二分时
while (l <= r){
        int mid = (l + r)/2;
        if (ui*mid - (n - mid)*di >= val) {
            r = mid - 1;
            tp = mid;
        }
        else {
            l = mid + 1;
        }
    }
    return tp*ui - (n - tp)*di;
}这个返回大于等于0的值,错了。
而
 while (l <= r){
        int mid = (l + r)>>1;
        if (ui*mid - (n - mid)*di > val) r = mid - 1;
        else {
            l = mid + 1;
        }
    }
    return l*ui - (n - l)*di;
}这个返回第一个大于0的值,结果AC了。。很是疑问? 求解释。。。。

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator