0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-05 02:06:27 +00:00
OI-codes/BZOJ/3834/3834.cpp

28 lines
480 B
C++

#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
int n, a, b, c, d, ans;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
while (n--) {
cin >> a >> b >> c >> d;
for (int i = 1, j; i <= std::min(b, d); i = j + 1) {
j = std::min(b / (b / i), d / (d / i));
if (b / j * j >= a && d / j * j >= c) ans = j;
}
cout << ans << endl;
}
return 0;
}