speed/Speed_artur.java

  1 import java.util.Scanner;
  2 
  3 public class Speed_artur {
  4 
  5   public static void main(String[] args) {
  6     Scanner in = new Scanner(System.in);
  7     while (true) {
  8       int d = in.nextInt();
  9       int s1 = in.nextInt();
 10       int s2 = in.nextInt();
 11       if (d == 0 && s1 == 0 && s2 == 0)
 12         break;
 13 
 14       double time1 = d * 3600.0 / s1;
 15       double time2 = d * 3600.0 / s2;
 16 
 17       double diff = time1 - time2;
 18       System.out.printf("%d:%02d:%02d\n", (int) (diff / 3600), (int) (diff % 3600 / 60), (int) (diff % 60 + 0.5));
 19     }
 20   }
 21 }