fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7.  
  8. public class Main {
  9. public static double distance (double X1,double X2,double Y1,double Y2)
  10. {
  11. return (Math.sqrt((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2)));
  12. }
  13. public static void main(String[] args) {
  14. Scanner sc = new Scanner(System.in);
  15. double A = sc.nextDouble();
  16. double B = sc.nextDouble();
  17. double C = sc.nextDouble();
  18. double X1 = sc.nextDouble();
  19. double Y1 = sc.nextDouble();
  20. double X2 = sc.nextDouble();
  21. double Y2 = sc.nextDouble();
  22. double Z2 = sc.nextDouble();
  23. double result_distance = Double.MAX_VALUE;
  24. if (Z2==0) result_distance = distance(X1,X2,Y1,Y2);//"floor" case
  25. else
  26. {
  27. if (X2==0) {
  28. X2=-Z2;
  29. result_distance = distance (X1,X2,Y1,Y2);
  30. }//"left wall" case
  31. if (X2==A) {
  32. X2=A+Z2;
  33. result_distance = distance (X1,X2,Y1,Y2);
  34. }//"right wall" case
  35. if (Y2==0) {
  36. Y2=-Z2;
  37. result_distance = Math.min(result_distance, distance (X1,X2,Y1,Y2));
  38. }//"near wall" case
  39. if (Y2==B) {
  40. Y2=B+Z2;
  41. result_distance = Math.min(result_distance, distance (X1,X2,Y1,Y2));
  42. }//"distant wall" case
  43. }
  44. System.out.printf("%.2f", result_distance);
  45. }
  46. }
  47.  
Runtime error #stdin #stdout #stderr 0.08s 2184192KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.util.NoSuchElementException
	at java.util.Scanner.throwFor(Scanner.java:862)
	at java.util.Scanner.next(Scanner.java:1485)
	at java.util.Scanner.nextDouble(Scanner.java:2413)
	at Main.main(Main.java:15)