fork download
  1. import java.util.*;
  2.  
  3. class Main
  4. {
  5. public static void main (String[] args)
  6. {
  7. Scanner in = new Scanner(System.in);
  8. double a, y;
  9. a = in.nextDouble();
  10. if (a < -1){
  11. y = 1/(a*a);
  12. }
  13. else{
  14. if (a >= -1 && a <= 2) y = a*a;
  15. else y = 4;
  16. }
  17. System.out.printf("%.8f\n", y);
  18. }
  19. }
Success #stdin #stdout 0.13s 2841600KB
stdin
1
stdout
1.00000000