Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def read_matrix():
- return [list(map(float, input().split())) for _ in range(3)]
- def transponse(a):
- return [[a[j][i] for j in range(3)] for i in range(3)]
- a = transponse(read_matrix())
- # sum(aik * zi) >= 1
- # sum(zi) -> min
- min_val = 1e18
- ans = [0, 0, 0]
- def func(a, z1, z2, z3):
- for i in range(3):
- if a[i][0] * z1 + a[i][1] * z2 + a[i][2] * z3 < 1:
- return 1e18
- return z1 + z2 + z3
- for i in range(101):
- for j in range(101):
- for k in range(101):
- res = func(a, i / 100, j / 100, k / 100)
- if res < min_val:
- min_val = res
- ans = [i / 100, j / 100, k / 100]
- print(min_val)
- print(ans)
- print([ans[i] / min_val for i in range(3)])
- a = transponse(a)
- max_val = -1e18
- ans = [0, 0, 0]
- def func(a, z1, z2, z3):
- for i in range(3):
- if a[i][0] * z1 + a[i][1] * z2 + a[i][2] * z3 > 1:
- return -1e18
- return z1 + z2 + z3
- for i in range(101):
- for j in range(101):
- for k in range(101):
- res = func(a, i / 100, j / 100, k / 100)
- if res > max_val:
- max_val = res
- ans = [i / 100, j / 100, k / 100]
- print(max_val)
- print(ans)
- print([ans[i] / max_val for i in range(3)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement