Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import stdin
- from copy import deepcopy
- class Matrix(object):
- def __init__(self, x):
- self.mat = deepcopy(x)
- def __str__(self):
- sR = ""
- a = 0
- for mat in self.mat:
- if a != 0:
- sR += "\n"
- new_s = "\t".join(str(i) for i in mat)
- sR += new_s
- a += 1
- return sR
- def size(self):
- return len(self.mat), len(self.mat[0])
- def __add__(self, other):
- return Matrix(list(map(
- lambda x, y: list(map(lambda z, w: z + w, x, y)),
- self.mat, other.matrix)))
- def __mul__(self, other):
- return Matrix([[i * other for i in j] for j in self.mat])
- __rmul__ = __mul__
- exec(stdin.read())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement