A Simple Multiplication

View as PDF

Submit solution

Points: 12
Time limit: 0.15s
Memory limit: 2M

Problem type
Allowed languages
Assembly, Lisp, NASM, NASM64

Your computer engineering instructor decided to give you another task (you are the best in the class, after all):

Write a program that prints the result of N ^ P \bmod M.

Unimpressed by the supposed challenge, you open up you favourite text editor (Vim, of course) and begin typing away\ldots in assembly.

Input Specification

The first line will contain 3 space-separated integers, N (1 \le N \le 100), P (1 \le P \le 10^9), and M (P < M \le 10^9 + 7).

Output Specification

The result of N^P \bmod M.

Sample Input 1

2 5 11

Sample Output 1


Sample Input 2

9 100 1000000007

Sample Output 2



To use libc in NASM, the first line of your program should be ; libc. For all others, it should be ; features: libc.


There are no comments at the moment.