ответ:я не уверена в ответах(давно не решала такие задачи)
16
[29, 31]
[28, 30]
12
[21, 23]
[20, 22]
Объяснение:
def moves(heap):
a,b=heap
return[(a+1,b),(2*a,b),(a,b+1),(a,b*2)]
table={(k,s):0 for k in range(501)for s in range(501)}
for x in table:
if any(sum(t)>=69 for t in moves(x)):
table[x]=1
if table[x]==0 and all(table[t]==1 for t in moves(x)):
table[x]=2
if table[x]==0 and any(table[t]==2 for t in moves(x)):
table[x]=3
if table[x]==0 and all(table[t]==3 or table[t]==1 for t in moves(x)):
table[x]=4
print(min([s for s in range(1,118)if any(table[t]==1 for t in moves((5,s)))]))
print([s for s in range(1,118)if table[(5,s)]==3])
print([s for s in range(1,118)if table[(5,s)]==4])
if any(sum(t)>=53 for t in moves(x)):
матрица заполняется случайно
программа на pascalabc
Var
max,min,mina,minb,maxa,maxb,a,b,c: integer;
mas: array[1..3,1..3] Of integer;
Begin
writeln('до :');
For a:=1 To 3 Do
For b:=1 To 3 Do
mas[a,b] := random(100);
If mas[a,b]>max Then
max := mas[a,b];
maxa := a;
maxb := b;
End;
If (min=0)Or(mas[a,b]<min) Then
min := mas[a,b];
mina := a;
minb := b;
write(mas[a,b],' ');
c := mas[maxa,maxb];
mas[maxa,maxb] := mas[mina,minb];
mas[mina,minb] := c;
writeln;
writeln('после :');
ответ:я не уверена в ответах(давно не решала такие задачи)
16
[29, 31]
[28, 30]
12
[21, 23]
[20, 22]
Объяснение:
def moves(heap):
a,b=heap
return[(a+1,b),(2*a,b),(a,b+1),(a,b*2)]
table={(k,s):0 for k in range(501)for s in range(501)}
for x in table:
if any(sum(t)>=69 for t in moves(x)):
table[x]=1
for x in table:
if table[x]==0 and all(table[t]==1 for t in moves(x)):
table[x]=2
for x in table:
if table[x]==0 and any(table[t]==2 for t in moves(x)):
table[x]=3
for x in table:
if table[x]==0 and all(table[t]==3 or table[t]==1 for t in moves(x)):
table[x]=4
print(min([s for s in range(1,118)if any(table[t]==1 for t in moves((5,s)))]))
print([s for s in range(1,118)if table[(5,s)]==3])
print([s for s in range(1,118)if table[(5,s)]==4])
def moves(heap):
a,b=heap
return[(a+1,b),(2*a,b),(a,b+1),(a,b*2)]
table={(k,s):0 for k in range(501)for s in range(501)}
for x in table:
if any(sum(t)>=53 for t in moves(x)):
table[x]=1
for x in table:
if table[x]==0 and all(table[t]==1 for t in moves(x)):
table[x]=2
for x in table:
if table[x]==0 and any(table[t]==2 for t in moves(x)):
table[x]=3
for x in table:
if table[x]==0 and all(table[t]==3 or table[t]==1 for t in moves(x)):
table[x]=4
print(min([s for s in range(1,118)if any(table[t]==1 for t in moves((5,s)))]))
print([s for s in range(1,118)if table[(5,s)]==3])
print([s for s in range(1,118)if table[(5,s)]==4])
матрица заполняется случайно
программа на pascalabc
Var
max,min,mina,minb,maxa,maxb,a,b,c: integer;
mas: array[1..3,1..3] Of integer;
Begin
writeln('до :');
For a:=1 To 3 Do
For b:=1 To 3 Do
Begin
mas[a,b] := random(100);
If mas[a,b]>max Then
Begin
max := mas[a,b];
maxa := a;
maxb := b;
End;
If (min=0)Or(mas[a,b]<min) Then
Begin
min := mas[a,b];
mina := a;
minb := b;
End;
write(mas[a,b],' ');
End;
c := mas[maxa,maxb];
mas[maxa,maxb] := mas[mina,minb];
mas[mina,minb] := c;
writeln;
writeln('после :');
For a:=1 To 3 Do
For b:=1 To 3 Do
write(mas[a,b],' ');