(defun matrix-multiply (m1 m2) "Multiplies two 2x2 matrices." (let* ((a1 (first (first m1))) (b1 (second (first m1))) (c1 (first (second m1))) (d1 (second (second m1))) (a2 (first (first m2))) (b2 (second (first m2))) (c2 (first (second m2))) (d2 (second (second m2)))) (list (list (+ (* a1 a2) (* b1 c2)) (+ (* a1 b2) (* b1 d2))) (list (+ (* c1 a2) (* d1 c2)) (+ (* c1 b2) (* d1 d2)))))) (defun matrix-power (matrix n) "Raises a 2x2 matrix to the nth power." (if (= n 1) matrix (matrix-multiply matrix (matrix-power matrix (1- n))))) (defun main () (let* ((matrix (list (list (read) (read)) (list (read) (read)))) ; 例として 1 2 ; 3 4 の行列を使用 (result (matrix-power matrix 3))) (format t "~{~{~a ~}~%~}" result))) (main)