fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. static double f (double x, double x0, double x1, double y, double y0, double y1){
  11. return (x - x0) * (y1 - y0) - (y - y0) * (x1 - x0);
  12. }
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. double xa, ya, xb, yb, xc, yc, xd, yd;
  16. Scanner in = new Scanner(System.in);
  17. xa = in.nextDouble();
  18. ya = in.nextDouble();
  19. xb = in.nextDouble();
  20. yb = in.nextDouble();
  21. xc = in.nextDouble();
  22. yc = in.nextDouble();
  23. xd = in.nextDouble();
  24. yd = in.nextDouble();
  25. double l,m;
  26. l = f(xc,xb,xa,yc,yb,ya);
  27. m = f(xd,xb,xa,yd,yb,ya);
  28. if (l * m < 0) {
  29. System.out.printf("не выпуклый");
  30. return;
  31. }
  32. double q,w;
  33. q = f(xa,xc,xb,ya,yc,yb);
  34. w = f(xd,xc,xb,yd,yc,yb);
  35. if (q * w < 0) {
  36. System.out.printf("не выпуклый");
  37. return;
  38. }
  39. double p,r;
  40. p = f(xa,xd,xc,ya,yd,yc);
  41. r = f(xb,xd,xc,yb,yd,yc);
  42. if (p * r < 0) {
  43. System.out.printf("не выпуклый");
  44. return;
  45. }
  46. double j,k;
  47. j = f(xb,xa,xd,yb,ya,yd);
  48. k = f(xc,xa,xd,yc,ya,yd);
  49. if (j * k < 0) {
  50. System.out.printf("не выпуклый");
  51. return;
  52. }
  53. System.out.printf(" Выпуклый ");
  54. }
  55. }
Success #stdin #stdout 0.15s 321280KB
stdin
1 0 1 3 2 1 5 0
stdout
не выпуклый