【題目敘述】http://codeforces.com/contest/1400/problem/B
#include <iostream>
using namespace std;
long long t, x, y, n, m, s, w;
int main() {
cin >> t;
while (t--){
cin >> x >> y >> n >> m >> s >> w;
if (s > w){
swap(n, m);
swap(s, w);
}
if (x/s+y/s <= n){
cout << x/s+y/s << "\n";
continue;
}
long long ans = 0;
for (int i = 0; i <= n; i++){
if (i*s > x || (n-i)*s > y) continue;
long long tmp = (x-i*s)/w + (y-(n-i)*s)/w;
tmp = min(tmp, m);
ans = max(ans, tmp);
}
ans += n;
cout << ans << "\n";
}
}