fork download
  1. program tulips2;
  2.  
  3. const
  4. MAXN = 100000;
  5.  
  6. var
  7. K, N, bottomLeftX, bottomLeftY, bottomRightX, bottomRightY, i, topLeftX, topLeftY, topRightX, topRightY, angoloacuto, angolottuso, primo,secondo, terzo,quarto : LongInt;
  8. X, Y : Array[0..MAXN-1] of LongInt;
  9.  
  10. function prodottoscalare(x1,y1,x2,y2,x3,y3,x4,y4:LongInt):LongInt;
  11. var componenti:array[1..2,1..2] of LongInt;
  12. begin
  13. componenti[1,1]:=x2-x1;
  14. componenti[1,2]:=y2-y1;
  15. componenti[2,1]:=x4-x3;
  16. componenti[2,2]:=y4-y3;
  17. prodottoscalare:= componenti[1,1]* componenti[2,1]+componenti[1,2]* componenti[2,2];
  18. end;
  19.  
  20. begin
  21.  
  22. {
  23.   uncomment the two following lines if you want to read/write from files
  24.   assign(input, 'input.txt'); reset(input);
  25.   assign(output, 'output.txt'); rewrite(output);
  26. }
  27.  
  28. ReadLn(topLeftX, topLeftY);
  29.  
  30. ReadLn(topRightX, topRightY);
  31.  
  32. ReadLn(bottomRightX, bottomRightY);
  33.  
  34. ReadLn(bottomLeftX, bottomLeftY);
  35.  
  36. ReadLn(N);
  37.  
  38. for i:=0 to N-1 do
  39. ReadLn(X[i], Y[i]);
  40.  
  41. K := 0;
  42.  
  43. for i:=0 to N-1 do
  44. begin
  45. angoloacuto:=0; angolottuso:=0;
  46. primo:=prodottoscalare(X[i],Y[i],topLeftX, topLeftY,X[i],Y[i],bottomLeftX, bottomLeftY);
  47. if primo<0 then angoloacuto:=angoloacuto+1
  48. else if primo>0 then angolottuso:=angolottuso+1;
  49. secondo:=prodottoscalare(X[i],Y[i],topLeftX, topLeftY,X[i],Y[i],topRightX, topRightY);
  50. if secondo<0 then angoloacuto:=angoloacuto+1
  51. else if secondo>0 then angolottuso:=angolottuso+1;
  52. terzo:=prodottoscalare(X[i],Y[i],bottomLeftX, bottomLeftY,X[i],Y[i],bottomRightX, bottomRightY);
  53. if terzo<0 then angoloacuto:=angoloacuto+1
  54. else if terzo>0 then angolottuso:=angolottuso+1;
  55. quarto:=prodottoscalare(X[i],Y[i],topRightX, topRightY,X[i],Y[i],bottomRightX, bottomRightY);
  56. if quarto<0 then angoloacuto:=angoloacuto+1
  57. else if quarto>0 then angolottuso:=angolottuso+1;
  58. if (angoloacuto=2) and (angolottuso=2) then k:=k+1;
  59. end;
  60. WriteLn(K);
  61. end.
  62.  
Success #stdin #stdout 0.01s 5280KB
stdin
0 35
35 35
35 0
0 0
10
17 8
16 5
32 27
18 32
8 18
17 30
14 19
5 11
2 32
2 11

stdout
4