Can You Exponentiate?
Time limit1sMemory limit128 MB
Given a and b up to 1e9, print the last decimal digit of a^b.
- Level
Easy3 of 10
- Topics
- Math, Number theory, Bit manipulation
- Solved
- No attempts yet
Problem
Given two natural numbers and , find the last (least significant) digit of .
Write a program that:
- reads the base and the exponent ,
- computes the last digit of ,
- prints the result.
Input
The first and only line contains two integers and separated by a single space ().
Output
Print only the last (least significant) digit of written in decimal.