P18943 [GeeksforGeeks] The invariable units digit3855
普及-
题目描述

Given two numbers N and P, the task is to check if unit digit of N and N^{P}^{ }are the same or not.
Example 1:
Input: N = "2", P = 1
Output: 1
Explanation: Unit digit of 2^{1} is 2,
which is equals to 2
Example 2:
Input: N = "4", P = 2
Output: 0
Explanation: Unit digit of 4^{2} is 6,
which is not equals to 4
Your Task:
You don't need to read input or print anything. Your task is to complete the function unitDigit() which takes a string N and an integer P as inputs and returns the boolean value.
Expected Time Complexity: O(|P|).
Expected Auxiliary Space: O(1).
Constraints:
1 <= |N| <= 50
1 <= P <= 1000

输入格式

见题面

输出格式

见题面

样例输入
N = "2", P = 1
样例输出
1