fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner scan = new Scanner(System.in);
  10. double x0 = scan.nextDouble();
  11. double y0 = scan.nextDouble();
  12. double x1 = scan.nextDouble();
  13. double y1 = scan.nextDouble();
  14. double x2 = scan.nextDouble();
  15. double y2 = scan.nextDouble();
  16. double x3 = scan.nextDouble();
  17. double y3 = scan.nextDouble();
  18. double z1,z2,z3;
  19. z1 = (x1 - x0) * (y2 - y1) - (x2 - x1) * (y1 - y0);
  20. z2 = (x2 - x0) * (y3 - y2) - (x3 - x2) * (y2 - y0);
  21. z3 = (x3 - x0) * (y1 - y3) - (x1 - x3) * (y3 - y0);
  22. if ((z1>=0 && z2>=0 && z3>=0) || (z1<=0 && z2<=0 && z3<=0)) System.out.println("1");
  23. else System.out.println("0");
  24. }
  25. }
Success #stdin #stdout 0.08s 2184192KB
stdin
1 1 -1 0 2 4 4 1
stdout
1