Submission details
Task:Exponentiation
Sender:francden
Submission time:2025-11-15 21:40:53 +0200
Language:Python3 (PyPy3)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.14 sdetails
#2ACCEPTED0.74 sdetails
#3ACCEPTED0.72 sdetails

Code

n = int(input())

MOD = 10**9 +7
def exp(a,b):
    exp_a = []
    k = 1
    exp_a.append(a)
    x = 1
    index = 0
    while k <= b:
        x = (x*exp_a[-1])%MOD
        exp_a.append(x)
        k*=2
        index+=1
    res = 1
    while b !=0:
        if k <= b:
            b -= k
            res = (res * exp_a[index+1])%MOD
        index-=1
        k//=2
    return res


for i in range (n):
    a,b = [int(x) for x in input().split()]

    print(exp(a,b))

Test details

Test 1

Verdict: ACCEPTED

input
10201
0 0
0 1
0 2
0 3
...

correct output
1
0
0
0
0
...

user output
1
0
0
0
0
...
Truncated

Test 2

Verdict: ACCEPTED

input
200000
129612095 411099530
241615980 487174929
60862511 511830781
758816482 982657640
...

correct output
276067146
838400234
148093882
546897305
467086232
...

user output
276067146
838400234
148093882
546897305
467086232
...
Truncated

Test 3

Verdict: ACCEPTED

input
200000
692427692 536870911
252480658 536870911
505090334 536870911
27194853 536870911
...

correct output
940305728
707431813
917260341
908974199
375947818
...

user output
940305728
707431813
917260341
908974199
375947818
...
Truncated