Problem T: 求X的Y次方 快速幕

Problem T: 求X的Y次方 快速幕

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

XY是正整数,求XY次方。由于答案可能很大,我们只要输出求答案%100000007
80分程序: (超时)
c,d=map(int,input().split())
print(c**d%100000007)


100分程序
def f(a,b):
    if b==0:
        return 1
    if b%2==1:
        return a*f(a,b-1)%100000007
    else:
        return f(a*a%100000007,b/2)%100000007

c,d=map(int,input().split())
print(f(c,d))

Input

第一行2个正整数:X Y
X范围[1, 1000000]
Y范围[0, 100000000000]


Output

答案%100000007

Sample Input Copy

123 10000

Sample Output Copy

40024626