Войти
или
Зарегистрироваться
Курсы
Учебник
Учебник 2.0
ОГЭ/ЕГЭ
Олимпиады
Рубрикатор
Компилятор
Статья Автор:
Комиссаров Всеволод
Задания перебор
#номер1 arr = [] n = 0 answer = 0 with open("input") as f: n = int(f.readline()) for _ in range(n): arr.append(int(f.readline())) for i in range(n): for j in range(i + 1, n): p = arr[i] * arr[j] if p % (10 ** 6) == 0 and p % (10 ** 7) != 0: answer += 1 print(answer) print(answer)
×
#номер2 arr = [] n = 0 answer = 0 with open("/home/student/Загрузки/27-45792A.txt") as f: n = int(f.readline()) for _ in range(n): arr.append(int(f.readline())) for i in range(n): for j in range(i + 1, n): p = arr[i] * arr[j] if p % 2310 == 0 and (arr[i] + arr[j]) % (11) == 0: answer += 1 print(answer) print(answer)
×
#номер3 arr = [] n = 0 answer = 0 k = 0 with open("27-45782A (1).txt") as f: n, k = map(int, f.readline().split()) for _ in range(n) : arr.append(int(f.readline())) for i in range(n - 2 * k): s = 0 s = sum(arr[i : i + k]) for j in range(i + 2 * k, n): s1 = sum(arr[j - k + 1: j + 1]) if (s + s1) % 68 == 0 and s + s1 > answer: answer = s + s1 print(answer) print(answer)
×
#номер 5 arr = [] n = 0 answer = 0 M = 0 with open("27-45786A.txt") as f: n, M = map(int, f.readline().split()) for _ in range(n) : arr.append(int(f.readline())) for i in range(n): now = 0 have = M house = i while have >= 0 and house < n: have -= arr[house] now += 1 house += 1 #print(have, now, house) if now - 1 > answer: answer = now - 1 print(answer) print(answer)
×
#номер 6 m = 17 M = 7717 arr = [] n = 0 answer = 0 with open("27-45788A.txt") as f: n = int(f.readline()) for _ in range(n) : arr.append(int(f.readline())) for i in range(n-m*2): for j in range(i+m, n-m): for k in range(j+m, n): if (arr[i] + arr[j] + arr[k]) % M == 0: answer += 1 print(answer) #print(arr[i], arr[j], arr[k]) print(answer)
×
#номер 8 arr = [] n = 0 answer = 0 with open("27A_6638.txt") as f: n = int(f.readline()) for _ in range(n) : arr.append(tuple(map(int, f.readline().split()))) answer = arr[0][0] answer_s = 0 for j in range(n): answer_s += (arr[j][0] - arr[0][0]) * arr[j][1] for i in range(n): now_s = 0 now_position = arr[i][0] for j in range(n): now_s += abs(arr[j][0] - arr[i][0]) * arr[j][1] if now_s < answer_s: answer = now_position answer_s = now_s print(answer, answer_s) #print(now_s, answer_s) print(answer)
×
Чтобы оставить комментарий нужна авторизация
Печать