P14344 [GeeksforGeeks] Find unit digit in a product2059
普及-
题目描述

Given 6 numbers a,b,c,d,e,f. Find the last digit of (a^{b})(c^{d})(e^{f}).

Example 1:
Input:
a = 3
b = 66
c = 6
d = 41
e = 7
f = 53
Output:
8
Explanation:
The last digit of the
value obtained after
solving the above
equation is 8.

Example 2:
Input:
a = 1
b = 1
c = 1
d = 1
e = 1
f = 1
Output:
1
Explanation:
The last digit of the
value obtained after
solving the above
equation is 1.

Your Task:
You don't need to read input or print anything. Your task is to complete the function theLastDigit() which takes 6 integers a, b, c, d, e, and f and returns the last digit of the value obtained from the equation.

Expected Time Complexity: O(sqrt(N))
Expected Auxiliary Space: O(1)

Constraints:
1 <= a,b,c,d,e,f <= 10^{9}

输入格式

见题面

输出格式

见题面

样例输入
a = 3 b = 66 c = 6 d = 41 e = 7 f = 53
样例输出
8