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 штук(а)
gears_count = int(input())
connections_count = int(input())
connections = []
for i in range(connections_count):
inp = input()
connections = connections + [[int(inp.split()[0]), int(inp.split()[1])]]
def get_connections_of_gear(gear=1, connections_arr=[[0]]):
gear_connections = 0
if connections_arr:
for i in range(connections_count * 2):
if connections_arr[i // 2][i % 2] == gear:
gear_connections += 1
return gear_connections
def is_valid():
if gears_count < 3 or connections_count < 3:
return "good"
elif gears_count % 2 == 0:
gears = 0
for i in range(gears_count):
if get_connections_of_gear(i, connections) > 2:
gears += 1
if gears % 2 == 0:
return "good"
elif not gears_count % 2 == 0:
gears = 0
for i in range(gears_count):
if get_connections_of_gear(i, connections) > 2:
gears += 1
if not gears % 2 == 0:
return "good"
return "bad"
print(is_valid())
Объяснение:
8 из 11