Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
疑问?题目说的是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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator