eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Положительные тесты

опубликовано 20.01.2024, 03:30:00

salam

опубликовано 03.02.2024, 18:29:57

from math import gcd diap=list(map(int, input().split())) a=diap[0] b=diap[1] counts=list(map(int, input().split())) try: lplus=list(map(int, input().split())) except: lplus=[]

try: lminus=list(map(int, input().split())) except: lminus=[]

def lcm(a, b): return abs(a * b) // gcd(a, b) if lplus==[] and lminus==[]: print(diap[1]-diap[0]+1) else:
if len(lplus)>0: LCM=1 for i in range(0, len(lplus)): LCM=lcm(LCM, lplus[i]) if a%LCM!=0:
a1=a+(LCM-a%LCM) else: a1=a count_plus=(b-a1)//LCM+1 diapazone=range(a1, a1+LCM*count_plus, LCM) if lminus==[]: print(len(diapazone)) else: c=0 for i in diapazone: k=False for j in lminus: if i%j==0: k=True break if k==False: c+=1 print(c) else: c=0 for i in range(diap[0], diap[1]+1): k=False for j in lminus: if i%j==0: k=True break if k==False: c+=1 print(c)