speed/Speed.java
1
2
3
4
5
6 import java.io.*;
7 import java.util.Scanner;
8 import java.util.*;
9
10 public final class Speed {
11
12 private static final Scanner STDIN =
13 new Scanner (new BufferedInputStream (System.in));
14
15 private static final PrintStream STDOUT =
16 new PrintStream (new BufferedOutputStream (System.out));
17
18 public static void main (final String[] args) {
19
20 input: for (int ds=1; ; ds++) {
21 final int d = STDIN.nextInt();
22 final int s1 = STDIN.nextInt();
23 final int s2 = STDIN.nextInt();
24 if (d==0 && s1==0 && s2==0) break;
25 assert 1<=d && d<=10_000;
26 assert 1<=s1 && s1<s2 && s2<=1_000;
27
28
29
30
31
32
33 final double time1 = 3600.0D * d / s1;
34 final double time2 = 3600.0D * d / s2;
35 final double diff = time1-time2;
36
37 final long interval = (long) Math.round (time1-time2);
38 final long hours = interval / 3600L;
39 final long minutes = (interval / 60L) % 60L;
40 final long seconds = interval % 60L;
41 System.out.printf ("%d:%02d:%02d\n", hours, minutes, seconds);
42 }
43 STDOUT.close();
44 }
45 }
46
47
48
49
50
51
52