Problems > Last K Digits of a Power

Last K Digits of a Power

Difficulty: 1400 2000 ms 128 MB

math

Print the last K digits of AB, padded with leading zeros to exactly K digits.

Input: one line with three integers A, B, K.

Output: the last K digits (zero-padded).

Constraints:

  • 1 ≤ A ≤ 109
  • 1 ≤ B ≤ 1018
  • 1 ≤ K ≤ 9

Sample Tests

Input 1
2 10 3
Output 1
024
Input 2
5 3 5
Output 2
00125

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.