Advertisement
smmac72

B

Apr 1st, 2021
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. import numpy as np
  2.  
  3. n = int(input())
  4.  
  5. # arr a
  6. A = np.diag(np.arange(1, n + 1))
  7.  
  8. # arr b
  9. re = np.r_[ (n // 2) * [1, 0] + (n % 2) * [1] ]
  10. ro = np.r_[ (n // 2) * [0, 1] + (n % 2) * [0] ]
  11. B = np.row_stack((n // 2) * (re, ro))
  12. if (np.shape(B)[0] != n):
  13.     B = np.vstack((B, re))
  14.  
  15. # arr c
  16.  
  17. C = np.ones((n,n), dtype = 'int')
  18. C[1:-1, 1:-1] = 0
  19. C = C * 10
  20.  
  21. # arr d
  22. D = np.linalg.inv(np.add(np.matmul(np.transpose(B), B), A)) + np.matmul(np.transpose(C), C)
  23. out = np.linalg.det(D)
  24.  
  25. print(out)
  26.  
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement