Easy Cyclist’s Training 12345678910111213141516171819202122#include <math.h>const double GRAVITY_ACC = 9.81 * 3.6 * 60.0;const double DRAG= 60.0 * 0.3 / 3.6;const double DELTA_T = 1.0 / 60.0;const double G_THRUST = 60.0 * 3.6 * 3.6;const double MASS = 80.0;const double WATTS0 = 225.0;const double D_WATTS = 0.5;int temps(double v0, double slope, double dTot) { double t = 0., gamma = 0., v = v0, d = 0., watts = WATTS0; while(d <= dTot) { gamma= -GRAVITY_ACC*sin(atan(slope/100)) - DRAG*abs(v)*abs(v)/MASS + ((watts>0 && v>0)? G_THRUST*watts/(v*MASS):0); if (abs(gamma)<=1e-5) gamma=0; watts-=D_WATTS*DELTA_T; v+=gamma*DELTA_T; if (v-3.0<=1e-2) return -1; d+=v*DELTA_T/60.0 ; t+=DELTA_T; } return round(t);}