begin var (cost, t, k) := (Arr(15, 70, 125, 230, 440), Arr(1, 5, 10, 20, 60), new integer[5]); var n := ReadInteger('n->'); for var i := 4 downto 0 do begin k[i] := n div t[i];n := n mod t[i]; end; if k[0] * cost[0] >= cost[1] then begin k[0] := 0;inc(k[1]); end; if k[0] * cost[0] + k[1] * cost[1] >= cost[2] then begin k[0] := 0;k[1] := 0;inc(k[2]); end; if k[0] * cost[0] + k[1] * cost[1] + k[2] * cost[2] >= cost[3] then begin k[0] := 0;k[1] := 0;k[2] := 0;inc(k[3]); end; if k[0] * cost[0] + k[1] * cost[1] + k[2] * cost[2] + k[3] * cost[3] >= cost[4] then begin k[0] := 0;k[1] := 0;k[2] := 0;k[3] := 0;inc(k[4]); end;
for var i := 0 to 4 do WritelnFormat('{0} билет(ов)- {1} штук(а)', t[i], k[i]); end.
//Версия 3.3, сборка 1634 (14.02.2018)
begin
var (cost, t, k) := (Arr(15, 70, 125, 230, 440), Arr(1, 5, 10, 20, 60), new integer[5]);
var n := ReadInteger('n->');
for var i := 4 downto 0 do
begin
k[i] := n div t[i];n := n mod t[i];
end;
if k[0] * cost[0] >= cost[1] then begin k[0] := 0;inc(k[1]); end;
if k[0] * cost[0] + k[1] * cost[1] >= cost[2] then
begin
k[0] := 0;k[1] := 0;inc(k[2]);
end;
if k[0] * cost[0] + k[1] * cost[1] + k[2] * cost[2] >= cost[3] then
begin
k[0] := 0;k[1] := 0;k[2] := 0;inc(k[3]);
end;
if k[0] * cost[0] + k[1] * cost[1] + k[2] * cost[2] + k[3] * cost[3] >= cost[4] then
begin
k[0] := 0;k[1] := 0;k[2] := 0;k[3] := 0;inc(k[4]);
end;
for var i := 0 to 4 do WritelnFormat('{0} билет(ов)- {1} штук(а)', t[i], k[i]);
end.
Пример(1):
n-> 37
1 билет(ов)- 0 штук(а)
5 билет(ов)- 0 штук(а)
10 билет(ов)- 0 штук(а)
20 билет(ов)- 0 штук(а)
60 билет(ов)- 1 штук(а)
Пример(2):
n-> 35
1 билет(ов)- 0 штук(а)
5 билет(ов)- 1 штук(а)
10 билет(ов)- 1 штук(а)
20 билет(ов)- 1 штук(а)
60 билет(ов)- 0 штук(а)
begin
var (cost, t, k) : = (arr(15, 70, 125, 230, 440), arr(1, 5, 10, 20, 60), new integer[5]);
var n : = readinteger('n-> ');
for var i : = 4 downto 0 do
begin
k[i] : = n div t[i]; n : = n mod t[i];
end;
if k[0] * cost[0] > = cost[1] then begin k[0] : = 0; inc(k[1]); end;
if k[0] * cost[0] + k[1] * cost[1] > = cost[2] then
begin
k[0] : = 0; k[1] : = 0; inc(k[2]);
end;
if k[0] * cost[0] + k[1] * cost[1] + k[2] * cost[2] > = cost[3] then
begin
k[0] : = 0; k[1] : = 0; k[2] : = 0; inc(k[3]);
end;
if k[0] * cost[0] + k[1] * cost[1] + k[2] * cost[2] + k[3] * cost[3] > = cost[4] then
begin
k[0] : = 0; k[1] : = 0; k[2] : = 0; k[3] : = 0; inc(k[4]);
end;
for var i : = 0 to 4 do writelnformat('{0} билет(ов)- {1} штук(а)', t[i], k[i]);
end.
пример(1):
n-> 37
1 билет(ов)- 0 штук(а)
5 билет(ов)- 0 штук(а)
10 билет(ов)- 0 штук(а)
20 билет(ов)- 0 штук(а)
60 билет(ов)- 1 штук(а)
пример(2):
n-> 35
1 билет(ов)- 0 штук(а)
5 билет(ов)- 1 штук(а)
10 билет(ов)- 1 штук(а)
20 билет(ов)- 1 штук(а)
60 билет(ов)- 0 штук(а)