fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.Scanner;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. double s1, s2, n, x;
  11. Scanner in = new Scanner(System.in);
  12. n = Double.parseDouble(in.nextLine());
  13. x = n * (5 - Math.sqrt(3) - Math.sqrt(6 * Math.sqrt(3) - 4))/(8 * (2 - Math.sqrt(3)));
  14. s1 = 4 * x; //Длина пути по дороге
  15. s2 = Math.sqrt(2 * (n * n - 4 * x * n + 8 * x * x));//Длина пути напрямую
  16. System.out.println(s1 + " " + s2);
  17. }
  18. }
Success #stdin #stdout 0.07s 4386816KB
stdin
21
stdout
28.98425718947506 22.46660550389587