P21668 [GeeksforGeeks] Abset 25327
普及-
题目描述

For two given positive numbers a and b. Find a^{b}. Output your number modulus 10^{9}+7.
Example 1:
Input: a = 1, b = 1
Output: 1
Explanation: 1^{1} % (10^{9}+7) = 1
​Example 2:
Input: a = 2, b = 5
Output: 32
Explanation: 2^{5} % (10^{9}+7) = 32
Your Task:
You don't need to read input or print anything. Your task is to complete the function power() which takes a, b as inputs, and returns the answer.
Expected Time Complexity: O(log b)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ a ≤ 10^{5}
1 ≤ b ≤ 10^{16}

输入格式

见题面

输出格式

见题面

样例输入
a = 1, b = 1
样例输出
1