fork download
  1. Program pavement;
  2.  
  3. var
  4. H, S, T, W, Totvert, Totor, restovert, restoor, angolo : Longint;
  5. pezzivertcheservono, pezziorizzcheservono, Totintere, Totpezzi, rimanente : Longint;
  6. begin
  7. (* assign(input, 'input.txt'); reset(input);
  8.   assign(output, 'output.txt'); rewrite(output);*)
  9.  
  10. ReadLn(H, W, S);
  11. T := 0;
  12. Totvert:=H div S; Totor:=W div S;
  13. Totintere:=Totvert*Totor;
  14. restovert:=H mod S; restoor:=W mod S;
  15. if (H=1) then
  16. begin
  17. if W mod S =0 then
  18. begin
  19. if ((W div S ) mod 2 =0) then T:= (W div S) div 2
  20. else T:= (W div S) div 2 +1;
  21. end
  22. else T:= (W div S) div 2 +1;
  23.  
  24. end
  25. else
  26. begin
  27. if (restovert=0) and (restoor=0) then
  28. begin
  29. pezzivertcheservono:=0;
  30. pezziorizzcheservono:=0;
  31. angolo:=0;
  32. end
  33. else
  34. begin
  35. pezzivertcheservono:=Totor;
  36. pezziorizzcheservono:=Totvert;
  37. if (restovert=0) then
  38. begin
  39. angolo:=0;
  40. if restoor * 2>S then pezziorizzcheservono:=Totvert
  41. else pezziorizzcheservono:=Totvert div 2;
  42. Totpezzi:=pezziorizzcheservono;
  43. end;
  44. if (restoor=0) then
  45. begin
  46. angolo:=0;
  47. if restovert * 2>S then pezzivertcheservono:=Totor
  48. else pezzivertcheservono:=Totor div 2;
  49. Totpezzi:=pezzivertcheservono;
  50. end;
  51. if (restovert<>0) and (restoor<>0) then
  52. begin
  53. if restovert+restoor<=S then
  54. begin
  55. if pezzivertcheservono>=Pezziorizzcheservono then
  56. begin
  57. Totpezzi:=pezziorizzcheservono;
  58. rimanente:=pezzivertcheservono-Pezziorizzcheservono;
  59. if rimanente=0 then angolo:=1
  60. else
  61. begin
  62. if restovert*2 <=S then
  63. begin
  64. if rimanente mod 2 =0 then begin Totpezzi:=Totpezzi+rimanente div 2; angolo:=1; end
  65. else begin Totpezzi:=Totpezzi+rimanente div 2 + 1; angolo:=0; end;
  66.  
  67. end
  68. else
  69. begin
  70. Totpezzi:=Totpezzi+rimanente;
  71. angolo:=1;
  72. end;
  73. end;
  74. end
  75. else
  76. begin
  77. Totpezzi:=pezzivertcheservono;
  78. rimanente:=pezziorizzcheservono-Pezzivertcheservono;
  79. if rimanente=0 then angolo:=1
  80. else
  81. begin
  82. if restoor*2 <=S then
  83. begin
  84. if rimanente mod 2 =0 then begin Totpezzi:=Totpezzi+rimanente div 2; angolo:=1; end
  85. else begin Totpezzi:=Totpezzi+rimanente div 2 + 1; angolo:=0; end;
  86.  
  87. end
  88. else
  89. begin
  90. Totpezzi:=Totpezzi+rimanente;
  91. angolo:=1;
  92. end;
  93. end;
  94. end;
  95. end
  96. else
  97. begin
  98. if restovert * 2>S then begin pezzivertcheservono:=Totor; angolo:=1; end
  99. else begin pezzivertcheservono:=Totor div 2; angolo:=0; end;
  100. if restoor * 2>S then begin pezziorizzcheservono:=Totvert;angolo:=1; end
  101. else begin pezziorizzcheservono:=Totvert div 2; angolo:=0; end;
  102. Totpezzi:=pezzivertcheservono+pezziorizzcheservono;
  103.  
  104. end;
  105. end;
  106. end;
  107.  
  108. T:=Totintere+Totpezzi+angolo;
  109. end;
  110. writeln(Totintere,' ',totpezzi,' ',angolo) ;
  111. WriteLn(T);
  112.  
  113. end.
Success #stdin #stdout 0s 5312KB
stdin
5 7 3
stdout
2 2 1
5