UVa 10515 - Powers Et Al.

Summary
In an expression$$m^n$$ find the last digit of the number.

Explanation
for 1 to n number=(number*m)%10; Divisibility: 1: any real number 2: last digit divisible by 2 4: last 2 digits divisible by 4. ie. 32 or 332 or 3333333332
 * A bad approach resulting in an overflow would be:
 * Another approach using number theory is find the number of changes in the last digit for m*n.
 * You do not need the entire 10^101 number in order to calculate last digit of m^n.
 * Oddly enough you only need the last digit of the first number and the last two digits of the second number.
 * Just a few hints with the number theory part.

Implementations

 * Code All the Problems

Input
2 2 2 5 2341423412 321423412342314124324234213421341324321 1232334445 13124123123123123123123123530930900480984530 0 0

Output
4 2 2 5