//Dennis Matveyev for SER 2013
//Speed Can Cost You
#include
#include
using namespace std;
/*
Idea: work this out on paper, put it into a formula and output.
cover both cases -- first speed can be higher/lower than the first speed.
Formulas:
Speed = Distance / Time
1 Hour = 60 Min = 3600 Seconds
Time = abs(Distance1 / Speed1 - Distance2 / Speed2)
*/
int main()
{
int miles, speed_a, speed_b;
while (cin >> miles >> speed_a >> speed_b && (miles != 0 || speed_a != 0 || speed_b != 0))
{
//magic happens here (worked out)
int seconds = 3600 * miles*(speed_a - speed_b) / (speed_a*speed_b);
if (seconds<0) seconds = -seconds;
int hours = seconds / 3600; seconds %= 3600;
int minutes = seconds / 60; seconds %= 60;
printf("%u:%02u:%02u\n", hours, minutes, seconds);
}
return 0;
}