Поиск задачи
8 Задание ЕГЭ ФИПИ по Информатика
Показать ответ
Решение:
import itertools
count = 0
for word in itertools.product('ЖИРАФ', repeat=4):
if word.count('Р') == 1:
count += 1
print(count)
Ответ: 256
Показать ответ
Решение:
import itertools
c = 0
for count, word in enumerate(itertools.product("АИНПТЦЯ", repeat=6), start=1):
if count % 2 == 0 and word[0] != "Н" and word.count('Я') == 2:
c += 1
print(c)
Ответ: 8640
Показать ответ
Решение:
import itertools
count = 0
for word in itertools.product("ЕНОС", repeat=4):
count += 1
if word[0] == 'С':
print(count)
break
Ответ: 193
Показать ответ
Решение:
import itertools
c = 0
for i, s in enumerate(tuple(itertools.product("АЖИМНУЧ", repeat=6))):
if s.count("Ч") <= 1 and i % 2 ==0:
if s[0] != 'Ж':
c += 1
print(c)
Ответ: 39528
Показать ответ
Решение:
import itertools
count = 0
# Перебираем все упорядоченные 5-ки разных цифр
# permutations сразу гарантирует, что все цифры различны
for digits in itertools.permutations('0123456789', 5):
# первые две проверки — пятизначность и делимость на 5
if digits[0] == '0':
continue
if digits[-1] not in ('0', '5'):
continue
# проверяем, что ни в одной соседней паре нет двух чётных или двух нечётных
flag = True
for a, b in zip(digits, digits[1:]):
if (int(a) % 2) == (int(b) % 2):
flag = False
break
if flag:
count += 1
print(count)
Ответ: 480
Показать ответ
Решение:
import itertools
c = 0
arr = []
for i in list(itertools.product('АГМНСТУ',repeat=6)):
s = ''.join(i)
c += 1
if s[0] != "У" and s.count("Г") <=1 and s.count("М") == 2:
arr.append(c)
print(arr[-1])
Ответ: 100810