Codeforces 185B(数学结论)
要点[*]有不等式\(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\n");
}
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\n", x, y, z);
}
文档来源:51CTO技术博客https://blog.51cto.com/u_14696602/3107448
页:
[1]