二分答案模板

xiaoxiao2021-02-27  489

遇到二分答案的题,只需要改变check里的内容即可

bool check(int mid) { if() return true; return false; } l = min; r = max; while(l<=r) { mid = (l+r)/2; if(check(mid)) { ans = mid; l = mid+1; } else r = mid-1; } cout<<ans<<endl;
转载请注明原文地址: https://www.6miu.com/read-1897.html

最新回复(0)