Войти
или
Зарегистрироваться
Курсы
Учебник
Учебник 2.0
ОГЭ/ЕГЭ
Олимпиады
Рубрикатор
Компилятор
Статья Автор:
Щурова Ольга
Как написать переборное решение к задаче типа 27 - Разбор
#1 name=input() mas=[] nulls=0 cnt=0 with open(name,'r') as file: n=int(file.readline()) for i in range(n): mas.append(int(file.readline())) for i in range(n): a=mas[i] for j in range(i+1,n): b=mas[j] m=str(a*b) r=len(m)-1 while m[r]=='0' and r>=0: nulls+=1 r-=1 if nulls==6: cnt+=1 nulls=0 print(cnt)
×
#2 name=input() mas=[] cnt=0 with open(name,'r') as file: n=int(file.readline()) for i in range(n): mas.append(int(file.readline())) for i in range(n): a=mas[i] for j in range(i+1,n): b=mas[j] s=a+b m=a*b if s%11==0 and m%2310==0:cnt+=1 print(cnt)
×
#3 name=input() mas=[] maxx=0 with open(name,'r') as file: n,k=map(int,file.readline().split()) for i in range(n): mas.append(int(file.readline())) for i in range(n-k): s1=sum(mas[i:i+k]) for j in range(i+k,n-k): s2=sum(mas[j:j+k]) s=s1+s2 #print(s1,s2,s) if s%68==0 and s>maxx: maxx=s print(maxx)
×
#8 name=input() s=0 mins=10000000000 dict={} with open(name,'r') as file: n=int(file.readline()) for i in range(n): x,y=map(int,file.readline().split()) dict[x]=y print(dict) for i in dict.keys(): for j in dict.keys(): s+=abs(i-j)*dict[j] if (s<mins) or (s==mins and i<x): x=i mins=s s=0 print(x,mins)
×
#7 name=input() cnt=0 mas=[] with open(name,'r') as file: n=int(file.readline()) for i in range(n): mas.append(int(file.readline())) #print(mas) for i in range(n): for j in range(i+25,n): if (mas[i]+mas[j])%4==0 and (mas[i]*mas[j])%9009==0: cnt+=1 print(cnt)
×
#6 name=input() cnt=0 mas=[] with open(name,'r') as file: n=int(file.readline()) for i in range(n): mas.append(int(file.readline())) for i in range(n): for j in range(i+17,n): for z in range(j+17,n): if (mas[i]+mas[j]+mas[z])%7717==0: cnt+=1 print(cnt)
×
#5 name=input() x=0 s=0 mas=[] with open(name,'r') as file: n,mx=map(int,file.readline().split()) for i in range(n): mas.append(int(file.readline())) for i in range(n): for j in range(i+1,n): s=sum(mas[i:j+1]) if s<=mx: x=max(j-i+1,x) else: break print(x)
×
#4 def check_num(num,dict,m): for i in dict.keys(): if abs(i-num)<m: return False return True name=input() summ=0 dict={} mins=10000000000000 with open(name,'r') as file: n,k,m=map(int,file.readline().split()) for i in range(n): x,y=map(int,file.readline().split()) dict[x]=y for i in range(1,k+1): if check_num(i,dict,m): for j in dict.keys(): summ+=min(abs(i-j),abs(k-i+j))*((dict[j]+19)//20) mins=min(mins,summ) summ=0 print(mins)
×
Чтобы оставить комментарий нужна авторизация
Печать