scripts/ege/28.03.2023 ПРОБНИК/Faily_IN11_28032023_/12.py
2023-05-05 00:45:01 +03:00

32 lines
777 B
Python

def is_prime(n):
for i in range(2, n):
if n % i == 0:
return False
return True
for r in range(200, 10000):
s = "0" + "2" * r + "1" * r + "210"
while "00" not in s:
s = s.replace("02", "101", 1)
s = s.replace("11", "2", 1)
s = s.replace("12", "21", 1)
s = s.replace("010", "00", 1)
n = sum([int(x) for x in s])
if is_prime(n):
print(s, n, r)
break
s = "0" + "2" * r + "1" * r + "0"
while "00" not in s:
s = s.replace("02", "101", 1)
s = s.replace("11", "2", 1)
s = s.replace("12", "21", 1)
s = s.replace("010", "00", 1)
n = sum([int(x) for x in s])
if is_prime(n):
print(s, n, r)
break