Created
July 26, 2017 19:48
-
-
Save MohamedTaha98/8b72c026d0a15a0a847529715e4d31e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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