Skip to content

Instantly share code, notes, and snippets.

@MohamedTaha98
Created July 26, 2017 19:48
Show Gist options
  • Save MohamedTaha98/8b72c026d0a15a0a847529715e4d31e1 to your computer and use it in GitHub Desktop.
Save MohamedTaha98/8b72c026d0a15a0a847529715e4d31e1 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class Taha {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
double x1 = in.nextDouble(), min = 0;
double y1 = in.nextDouble();
int n = in.nextInt();
double ar[] = new double [n];
for (int i = 0; i < n; i++) {
double x2 = in.nextDouble();
double y2 = in.nextDouble();
double speed = in.nextDouble();
double x = Math.pow(x1 - x2, 2);
double y = Math.pow(y1 - y2, 2);
double dist = Math.sqrt(x + y);
ar[i] = dist / speed;
if (min == 0)
min = ar[i];
else if (ar[i] < min)
min = ar[i];
}
for (int i = 0; i < n; i++) {
if (ar[i] < min)
min = ar[i];
}
System.out.printf("%.20f\n", min);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment