def make_tableau(A, b, c): m = len(A) n = len(A[0]) tableau = [] for i in range(m): row = A[i] + [int(j == i) for j in range(m)] + [b[i]] tableau.append(row) row = c + [0] * (m + 1) tableau.append(row) return tableau def pivot_index(tableau): cN = tableau[-1][:-1] piv_col = -1 for col, x in enumerate(cN): if x > 0: piv_col = col break if piv_col == -1: return False, -1, -1 a = [tableau[i][piv_col] for i in range(len(tableau) - 1)] b = [tableau[i][-1] for i in range(len(tableau) - 1)] thetas = [bi / ai if ai > 0 else float('inf') for ai, bi in zip(a, b)] piv_row = thetas.index(min(thetas)) if min(thetas) == float('inf'): raise Exception("解が非有界") return True, piv_row, piv_col def step(tableau, piv_row, piv_col): h = len(tableau) w = len(tableau[0]) piv = tableau[piv_row][piv_col] for j in range(w): tableau[piv_row][j] /= piv for i in range(h): if i == piv_row: continue d = tableau[i][piv_col] for j in range(w): tableau[i][j] -= d * tableau[piv_row][j] def simplex(A, b, c): tableau = make_tableau(A, b, c) while True: improved, piv_row, piv_col = pivot_index(tableau) if not improved: break step(tableau, piv_row, piv_col) return -tableau[-1][-1] C, D = map(int, input().split()) A = [ [3 / 4, 2 / 7], [1 / 4, 5 / 7] ] b = [C, D] c = [1000, 2000] print(simplex(A, b, c))