fork download
  1. uses
  2. SysUtils;
  3.  
  4. const
  5. c_of_chest = 1255;
  6. c_of_box = 114.5;
  7. c_of_disk = 11.5;
  8.  
  9. var
  10. num_of_d, num_of_b, num_of_c, n, bonus , total : Integer;
  11. cost , benefit : real;
  12. r_cost , r_benefit : string;
  13. begin
  14. { TODO -oUser -cConsole Main : Insert code here }
  15. writeln ('How many disks do you need?');
  16. readln(n);
  17.  
  18.  
  19. num_of_c := n div 144;
  20. num_of_d := n mod 144;
  21. num_of_b := num_of_d div 12;
  22. num_of_d := num_of_d mod 12;
  23. cost := (num_of_c*c_of_chest) + (num_of_b*c_of_box) + (num_of_d*c_of_disk);
  24.  
  25. if ((num_of_c + 1)*c_of_chest) < cost then
  26. begin
  27. num_of_c := num_of_c + 1;
  28. num_of_b := 0;
  29. num_of_d := 0 ;
  30. benefit := cost - ((num_of_c*c_of_chest) + (num_of_b*c_of_box) + (num_of_d*c_of_disk));
  31. cost := (num_of_c*c_of_chest) + (num_of_b*c_of_box) + (num_of_d*c_of_disk);
  32. end;
  33.  
  34. if ((num_of_c*c_of_chest) + ((num_of_b + 1)*c_of_box)) < cost then
  35. begin
  36. num_of_b := num_of_b + 1;
  37. num_of_d := 0 ;
  38. benefit := cost - ((num_of_c*c_of_chest) + (num_of_b*c_of_box) + (num_of_d*c_of_disk));
  39. cost := (num_of_c*c_of_chest) + (num_of_b*c_of_box) + (num_of_d*c_of_disk);
  40. end;
  41.  
  42.  
  43.  
  44. bonus := ((num_of_c*144) + (num_of_b*12) + (num_of_d)) - n;
  45.  
  46. if num_of_c > 0 then
  47. begin
  48. writeln('Chests: ', num_of_c);
  49. end;
  50.  
  51. if num_of_b > 0 then
  52. begin
  53. writeln('Boxes: ', num_of_b);
  54. end;
  55.  
  56. if num_of_d > 0 then
  57. begin
  58. writeln('Single disks:', num_of_d);
  59. end;
  60.  
  61. total := (num_of_c*144) + (num_of_b*12) + (num_of_d);
  62. writeln ('Total number of Disks: ', total);
  63.  
  64.  
  65. if bonus > 0 then
  66. begin
  67. writeln ('Bonus disks: ', bonus);
  68. end;
  69.  
  70. if benefit > 0 then
  71. begin
  72. r_benefit := FormatFloat('0.00', benefit);
  73. writeln ('Benefit: ', r_benefit , ' rubles');
  74. end;
  75.  
  76. r_cost := FormatFloat('0.00', cost);
  77.  
  78. writeln ('total cost: ' , r_cost ,' rubles');
  79.  
  80.  
  81.  
  82. readln;
  83. end.
Success #stdin #stdout 0s 5272KB
stdin
Standard input is empty
stdout
How many disks do you need?
Total number of Disks: 0
total cost: 0.00 rubles