Определите количество чисел, для записи которых в восьмеричной системе счисления требуется ровно
Приведем решение на языке Python.
from itertools import product as p
h = list(filter(lambda x: x.count('0') == 3 and '00' not in x, list(map(lambda x: ''.join(x), p('01', repeat=12)))))
p0 = len(list(p('0246', repeat=9))) * len([1 for i in h if i[0] == '0'])
p1 = len(list(filter(lambda x: x[0] != '0', p('0246', repeat=9)))) * len([1 for i in h if i[0] == '1'])
print(len(list(p('1357',repeat=3))) * (p0 + p1))
Ответ: 1660944384.
Приведем решение Бориса Савельева на языке Python.
from itertools import*
cnt1 = 0
cnt2 = 0
for i in product('НЧ', repeat = 12):
p = ''.join(i)
if p[0]=='Н' and p.count('Н')==3 and p.count('НН')==0:
cnt1 += 1
elif p[0]=='Ч' and p.count('Н')==3 and p.count('НН')==0:
cnt2 += 1
print(4**12*cnt1 + 3*4**11*cnt2)

