#include #include #include using namespace std; struct stage{ double m, t, F; }; int main(){ ifstream is("ame.in"); stage stages[60]; if(!is){ cerr << "Could not open" << endl; return 1; } int K; is >> K; for(int i=0; i < K; i++){ int n; double height = 0.0, currVel = 0.0, weight; is >> n; is >> weight; for(int x = 0; x < n; x++){ is >> stages[x].m; is >> stages[x].t; is >> stages[x].F; weight += stages[x].m; } for(int x = 0; x < n; x++){ double a = stages[x].F/weight - 9.81; height += currVel * stages[x].t + 0.5 * stages[x].t * stages[x].t * a; currVel += a * stages[x].t; weight -= stages[x].m; } printf("Data Set %d:\n", i+1); printf("%.2f\n", height); } return 0; }