- Problem C Careful Ascent
The poor we were stuck in attendance question was half done with the results written about the speed interval [0,1e32], and change [-1e32,1e32] on the adoption, hey ~ how no think about the range of the interval to change it.
Here is the normal mathematical solution, similar to solving a linear equation.
#include <iostream> using namespace std; typedef long long ll; ll x,y,n; ll a,b;double c; int main(){ cin>>x>>y>>n; ll sum = y; double X = 0; while (n--){ cin>>a>>b>>c; sum -= (b-a); X += (b-a)*c; } X += sum; printf("%.10f\n",(double)x/X); return 0; }