From 059ef4d85914c7e35f26b4abb4492e9f93e8de54 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 12 Oct 2022 11:13:31 +0800 Subject: [PATCH] P3579 [POI2014]PAN-Solar Panels https://www.luogu.com.cn/record/89548822 --- Luogu/P3579/P3579.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Luogu/P3579/P3579.cpp diff --git a/Luogu/P3579/P3579.cpp b/Luogu/P3579/P3579.cpp new file mode 100644 index 00000000..3fd15c76 --- /dev/null +++ b/Luogu/P3579/P3579.cpp @@ -0,0 +1,27 @@ +#include + +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; +}