C1: Doubling Powers

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 200

Problem Statement

You are given an integer nn and two positive integers aa and LL that are coprime.

For arbitrary integer kk satisfying 0k<n0 \leq k < n, calculate a2k mod La^{2^k}\ \text{mod}\ L.

Constraints

  • 1n1051 \leq n \leq 10^5
  • 1a<L210241 \leq a < L \leq 2^{1024}
  • Results must be returned as a Python's list in the form of [a20 mod La^{2^0}\ \text{mod}\ L, \cdots, a2n1 mod La^{2^{n-1}}\ \text{mod}\ L].
  • The submitted code must follow the specified format:
def solve(n: int, a: int, L: int) -> list[int]:
    result: list[int] = []
    # Write your code here:
 
    return result

Please sign in to submit your answer.