算法
(暴力枚举) $O(w’)$
令 $w = 1000w$,$n$ 为挑选的橘子数量,则 $nA \leqslant w’ \leqslant nB$ .
C++ 代码
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::min;
using std::max;
int main() {
int a, b, w;
cin >> a >> b >> w;
w = 1000 * w;
const int INF = 1001001001;
int l = INF, r = -INF;
for (int n = 1; n <= w; ++n) {
if (a * n <= w and w <= b * n) {
l = min(l, n);
r = max(r, n);
}
}
if (l == INF) cout << "UNSATISFIABLE\n";
else cout << l << " " << r << '\n';
return 0;
}