speed/Speed_Calvin.java
1 import java.util.Scanner;
2
3 public class Speed_Calvin {
4 public static void main(String[] args) {
5 Scanner in = new Scanner(System.in);
6 while(in.hasNextLine()) {
7 String t = in.nextLine();
8 Scanner in2 = new Scanner(t);
9 if (t.equals("0 0 0")) {
10 break;
11 }
12 double d = in2.nextInt();
13 double s1 = in2.nextInt();
14 double s2 = in2.nextInt();
15 in2.close();
16 double ss1 = s1/3600.0;
17 double ss2 = s2/3600.0;
18 double t1 = d/ss1;
19 double t2 = d/ss2;
20 double d1 = t1 - t2;
21 int h = (int) (d1/3600);
22 d1 = d1 - 3600*h;
23 int m = (int) (d1 / 60);
24 d1 = d1 - 60 * m;
25 int s = (int) Math.round(d1);
26 String ms = String.valueOf(m);
27 String ss = String.valueOf(s);
28 if (m < 10) {
29 ms = "0" + ms;
30 }
31 if (s < 10) {
32 ss = "0" + ss;
33 }
34 System.out.println(h + ":" + ms + ":" + ss);
35 }
36 in.close();
37 }
38 }