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 штук(а)
- 10110
1001
1101 (2сс)
2)
-102
75
5 (8сс)
3)
+A1C5
6023
101E8 (16cc)
4)
16*8 (10cc) =2^4*2^3 =2^7 (10cc) = 10 000 000 (2cc)
4*4=2^4 (10cc) =10 000 (2cc)
1 (10cc) =1 (2cc)
10 000 000 +10 000 +1 =10 010 001 (2cc)
5)
- 1101
11
1010 > пропущена последовательность 01
проверка:
1101
-1010
11