Codeforces 115 div1 B.Mushroom Scientists
一开始其实有想到按abc的比例去分xyz
但是觉得算了
数学这么差没什么自信
事实上确实是这样
新学了琴生不等式和AMGM不等式用来证明这个
这里最好多输出几位小数,防止加起来因为四舍五入的原因超过S
#include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;
int main() {
int S,a,b,c; cin >> S >> a >> b >> c;
double x = 0,y = 0,z = 0;
if(a+b+c==0) {
x = y = z = S/3;
cout << S << " " << 0 << " " << 0;
return 0;
}
x = (double)(S*a)/(a+b+c);
y = (double)(S*b)/(a+b+c);
z = (double)(S*c)/(a+b+c);
printf("%.18lf %.18lf %.18lf",x,y,z);
return 0;
}