Войти
или
Зарегистрироваться
Курсы
Учебник
Учебник 2.0
ОГЭ/ЕГЭ
Олимпиады
Рубрикатор
Компилятор
Статья Автор:
Герасименко Фёдор
Задания 19_20_21
def Check(s, bound): x = s[0] y = s[1] return x + y <= bound def getS(s): x = s[0] y = s[1] res = [(x - 1, y), (x, y - 1), (x // 2, y), (x, y // 2)] return res def getOr(mass): res = mass[0] for i in range(1, len(mass)): res = (res or mass[i]) return res def getAnd(mass): res = mass[0] for i in range(1, len(mass)): res = (res and mass[i]) return res def play1(s, bound, h, mxh): if Check(s, bound): return h % 2 if h > mxh: return 0 moves = getS(s) r = [play1(el, bound, h + 1, mxh) for el in moves] if h % 2 == 0: return getOr(r) return getAnd(r) def play2(s, bound, h, mxh): if Check(s, bound): return (h + 1) % 2 if h > mxh: return 0 moves = getS(s) r = [play2(el, bound, h + 1, mxh) for el in moves] if h % 2 != 0: return getOr(r) return getAnd(r) def play2Bad(s, bound, h, mxh): if Check(s, bound): return (h + 1) % 2 if h > mxh: return 0 moves = getS(s) r = [play2Bad(el, bound, h + 1, mxh) for el in moves] return getOr(r) def play1Bad(s, bound, h, mxh): if Check(s, bound): return h % 2 if h > mxh: return 0 moves = getS(s) r = [play1Bad(el, bound, h + 1, mxh) for el in moves] return getOr(r) bound = 16 beg = 416 sgn = -1 x = 12 for s in range(beg, 1, sgn): if play2Bad((x, s), bound, 0, 1): print(s) print('##########################') for s in range(beg, 1, sgn): if not(play1((x, s), bound, 0, 0)) and play1((x, s), bound, 0, 2): print(s) print('##########################') for s in range(beg, 1, sgn): if play2((x, s), bound, 0, 3) and not(play2((x, s), bound, 0, 1)): print(s)
×
def Check(s, bound): x = s[0] y = s[1] return x + y >= bound def getS(s): x = s[0] y = s[1] res = [(x + 1, y), (x, y + 1), (x * 3, y), (x, y * 3)] return res def getOr(mass): res = mass[0] for i in range(1, len(mass)): res = (res or mass[i]) return res def getAnd(mass): res = mass[0] for i in range(1, len(mass)): res = (res and mass[i]) return res def play1(s, bound, h, mxh): if Check(s, bound): return h % 2 if h > mxh: return 0 moves = getS(s) r = [play1(el, bound, h + 1, mxh) for el in moves] if h % 2 == 0: return getOr(r) return getAnd(r) def play2(s, bound, h, mxh): if Check(s, bound): return (h + 1) % 2 if h > mxh: return 0 moves = getS(s) r = [play2(el, bound, h + 1, mxh) for el in moves] if h % 2 != 0: return getOr(r) return getAnd(r) def play2Bad(s, bound, h, mxh): if Check(s, bound): return (h + 1) % 2 if h > mxh: return 0 moves = getS(s) r = [play2Bad(el, bound, h + 1, mxh) for el in moves] return getOr(r) def play1Bad(s, bound, h, mxh): if Check(s, bound): return h % 2 if h > mxh: return 0 moves = getS(s) r = [play1Bad(el, bound, h + 1, mxh) for el in moves] return getOr(r) bound = 70 beg = 1 x = 4 for s in range(beg, bound - x): if play2Bad((x, s), bound, 0, 1): print(s) print('##########################') for s in range(beg, bound - x): if not(play1((x, s), bound, 0, 0)) and play1((x, s), bound, 0, 2): print(s) print('##########################') for s in range(beg, bound - x): if play2((x, s), bound, 0, 3) and not(play2((x, s), bound, 0, 1)): print(s)
×
def getS(s): res = [s + 1, s * 6] return res def getOr(mass): res = mass[0] for i in range(1, len(mass)): res = (res or mass[i]) return res def getAnd(mass): res = mass[0] for i in range(1, len(mass)): res = (res and mass[i]) return res def play1(s, bound, h, mxh): if s >= bound: return h % 2 if h > mxh: return 0 moves = getS(s) r = [play1(el, bound, h + 1, mxh) for el in moves] if h % 2 == 0: return getOr(r) return getAnd(r) def play2(s, bound, h, mxh): if s >= bound: return (h + 1) % 2 if h > mxh: return 0 moves = getS(s) r = [play2(el, bound, h + 1, mxh) for el in moves] if h % 2 != 0: return getOr(r) return getAnd(r) def play2Bad(s, bound, h, mxh): if s >= bound: return (h + 1) % 2 if h > mxh: return 0 moves = getS(s) r = [play2Bad(el, bound, h + 1, mxh) for el in moves] return getOr(r) def play1Bad(s, bound, h, mxh): if s >= bound: return h % 2 if h > mxh: return 0 moves = getS(s) r = [play1Bad(el, bound, h + 1, mxh) for el in moves] return getOr(r) bound = 366 beg = 1 for s in range(beg, bound): if play2Bad(s, bound, 0, 1): print(s) break print('##########################') for s in range(beg, bound): if not(play1(s, bound, 0, 0)) and play1(s, bound, 0, 2): print(s) print('##########################') for s in range(beg, bound): if play2(s, bound, 0, 3) and not(play2(s, bound, 0, 1)): print(s)
×
Чтобы оставить комментарий нужна авторизация
Печать