Matrix Exponentiation

Time: 4.0 s     Memory: 1024 MB
  • Input

    The first line of input contains two integers $N$ ($1 \leq N \leq 10$) and $k$ ($0 \leq k \leq 10$). The following $N$ lines contain $N$ integers each, the matrix $A$ ($0 \leq a_{ij} \leq 10$).

    Output

    Print $N$ lines with $N$ integers per line, the matrix $A^k$.

    The type of whitespace you use is not important, it’s acceptable to print the $N^2$ numbers on a single line.

    Sample Input 1 Sample Output 1
    2 7
    1 1
    1 0
    
    21 13
    13 8
    
    Sample Input 2 Sample Output 2
    3 0
    0 0 0
    0 0 0
    0 0 0
    
    1 0 0
    0 1 0
    0 0 1
    
Chalmers golftävling 2024
  •  
  • To solve the problems, you can either start a virtual contest or register for regular practice. A virtual contest simulates a participation in the original contest with a duration of 1 day, while regular practice lets you submit solutions without any constraints.

    You must log in to register.
  • Matrix Exponentiation
You must log in to submit solutions to the problem.
{"contest_start_timestamp": 1711922400, "contest_duration": 86400, "contest_started": true, "contest_ended": true, "flexible_start_window_end_time": null, "only_virtual": false}