思路:
直接推式子,然后枚举一行多少个箱子,然后判断就行
#include
#include
using namespace std;
long long l, n, m;
int main() {
scanf("%lld%lld%lld", &l, &n, &m);
if(n % l == 0 && m % l == 0) {
printf("0.00000");
return 0;
}
register long long ans = 0;
register long double k = 0.0;
for(register long long i = 1; i <= n; ++ i) {
long long r = i - 1;
if(n - r * l > 0) {
register long double x = (n * 1.0 - r * l * 1.0) / (i * 1.0);
if(x < 0) continue;
register long long h = (m * 1.0 - x) / (l * 1.0 + x);
if(h < 0) continue;
if(m - l * h >= 0) {
if((m - l * 1.0 * h) / (h + 1.0) == x) {
if(h * r > ans) ans = h * r, k = x;
}
}
}
else break;
}
if(ans == 0) printf("-1");
else printf("%.5Lf", k);
return 0;
}