https://codeforces.com/contest/1538/problem/G
一道很好的二分题目

//s + t = c
//s <= (x - c*b) / (a - b)
//t <= (y - c*b) / (a - b)
//s + t <= (x - c*b) / (a - b) + (y - c*b) / (a - b)
//c <= (x - c*b) / (a - b) + (y - c*b) / (a - b)
//因为不能合并,就变为与c有关的单调,每次check是否满足c <= (x - c*b) / (a - b) + (y - c*b) / (a - b)即可
ll x, y, a, b;
bool check(ll c) {
    ll xx = x - b * c;
    ll yy = y - b * c;
    if(a == b)
        return xx >= 0 && yy >= 0;
    else {
        if(xx < 0 || yy < 0)  return 0;
        xx /= (a - b);
        yy /= (a - b);
        return xx + yy >= c;
    }
}

void run() {
    cin >> x >> y >> a >> b;
    if(a < b)   swap(a, b);
    if(x < y)   swap(x, y);
    ll l = 0, r = 1e9, ans;
    while(r >= l){
        ll mid = l + r >> 1;
        if(check(mid)) ans = mid, l = mid + 1;
        else    r = mid - 1;
    }
    cout << ans << endl;
    return ;
}