n | def det_3(row1, row2, row3): | n | def count_det3_3(row1, row2, row3): |
| return row1[0] * row2[1] * row3[2] + row1[1] * row2[2] * row3[0] + row1[2] * row2[0] * row3[1] - row1[2] * row2[1] * row3[0] - row1[1] * row2[0] * row3[2] - row1[0] * row2[2] * row3[1] | | return row1[0] * row2[1] * row3[2] + row1[1] * row2[2] * row3[0] + row1[2] * row2[0] * row3[1] - row1[2] * row2[1] * row3[0] - row1[1] * row2[0] * row3[2] - row1[0] * row2[2] * row3[1] |
| | | |
n | def det4(row1, row2, row3, row4): | n | def count_det4_4(row1, row2, row3, row4): |
| return row1[0] * det_3(row2[1:], row3[1:], row4[1:]) - row2[0] * det_3(row1[1:], row3[1:], row4[1:]) + row3[0] * det_3(row1[1:], row2[1:], row4[1:]) - row4[0] * det_3(row1[1:], row2[1:], row3[1:]) | | return row1[0] * count_det3_3(row2[1:], row3[1:], row4[1:]) - row2[0] * count_det3_3(row1[1:], row3[1:], row4[1:]) + row3[0] * count_det3_3(row1[1:], row2[1:], row4[1:]) - row4[0] * count_det3_3(row1[1:], row2[1:], row3[1:]) |
| (row1, row2, row3, row4) = eval(input()) | | (row1, row2, row3, row4) = eval(input()) |
t | print(det4(row1, row2, row3, row4)) | t | print(count_det4_4(row1, row2, row3, row4)) |