这么是不是就不会损失在mid上的答案了?
while(l<=r) { int mid=(l+r)>>1; if(check(l,mid)) { ans=mid;//ans记录 r=mid-1; } else l=mid+1; } printf("%lld",ans);