fork download
  1. Program pavement;
  2.  
  3. var
  4. H, S, T, W, Totvert, Totor, restovert, restoor, angolo, Piastrelle : 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. end
  32. else
  33. begin
  34. pezzivertcheservono:=Totor;
  35. pezziorizzcheservono:=Totvert;
  36. if restovert+restoor<=S then
  37. begin
  38. if pezzivertcheservono>=Pezziorizzcheservono then
  39. begin
  40. Piastrelle:=0; writeln ('zz ',Pezziorizzcheservono);
  41. Totpezzi:=pezzivertcheservono;
  42. if Totpezzi mod 2 =0 then begin Piastrelle:=Totpezzi div 2; rimanente:=0; writeln('P1 ', piastrelle); end
  43. else begin Piastrelle:=Totpezzi div 2; rimanente:=1; writeln('P2 ', piastrelle); end;
  44. if Pezziorizzcheservono mod 2 =0 then Piastrelle:=Piastrelle+Pezziorizzcheservono div 2
  45. else
  46. begin
  47. rimanente:=rimanente+1;
  48. Piastrelle:=Piastrelle+Pezziorizzcheservono div 2;
  49. writeln( 'P3 ',piastrelle);
  50. end;
  51. writeln (rimanente);
  52. if rimanente mod 2=0 then begin Piastrelle:=Piastrelle+ rimanente div 2; rimanente:=0; end
  53. else begin Piastrelle:=Piastrelle+1; rimanente:=1; end;
  54. writeln( 'Pò ',piastrelle);
  55. end; end; end;end; end.
  56. end
  57. else
  58. begin
  59. Totpezzi:=pezziorizzcheservono;
  60. rimanente:=Totpezzi-Pezzivertcheservono;
  61. end;
  62. if (restovert=0) and (restoor=0) then angolo:=0
  63. else
  64. begin
  65. if (rimanente=0) then angolo:=1
  66. else angolo:=0;
  67. end;
  68. end
  69. else
  70. begin
  71. Totpezzi:= pezzivertcheservono+Pezziorizzcheservono;
  72. angolo:=1;
  73. end;
  74. end;
  75. T:=Totintere+Totpezzi+angolo;
  76. end;
  77. WriteLn(T);
  78.  
  79. end.
Success #stdin #stdout 0s 5316KB
stdin
7 6 3
stdout
zz 2
P1 1
0
Pò 2