要点
- 有不等式(x^ay^bz^c=a^ab^bc^c(frac{x}{a})^a(frac{y}{b})^b(frac{z}{c})^c<=a^ab^bc^c(frac{x+y+z}{a+b+c})^{a+b+c}),而本题中又有(x+y+z<=S),故可直接获得。
#include <cstdio>
int S, a, b, c;
int main() {
scanf("%d%d%d%d", &S, &a, &b, &c);
if (a + b + c == 0) {
return !printf("0 0 0
");
}
double x = (double)a / (a + b + c) * S;
double y = (double)b / (a + b + c) * S;
double z = (double)c / (a + b + c) * S;
printf("%.20lf %.20lf %.20lf
", x, y, z);
}