群星
水题
#include<iostream>
using namespace std;
const int MAX = 1e4 + 10;
double a, dm;
int n;
double io[MAX];
int main()
{
double up = 0, down = 0;
cin >> a >> dm >> n;
for (int i = 1; i <= n; i++)
cin >> io[i];
for (int i = 1; i <= n; i++)
{
double temp;
if (io[i] > 0)up += io[i];
if (io[i] < 0)down -= io[i];
if (up&&down) {
temp = dm * up / down;
printf("%.3f\n", temp);
}
else if (up) {
temp = dm * up;
printf("%.3f\n", temp);
}
else if (down) {
temp = dm / down;
printf("%.3f\n", temp);
}
else {
printf("%.3f\n", dm);
}
}
system("pause");
return 0;
}