Submission details
Task:Exponentiation
Sender:aalto26kh_004
Submission time:2026-11-11 20:02:03 +0200
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#10.10 sdetails
#2--details
#3--details

Code

from math import log2, ceil, floor
import sys
def main():
    n = int(input())
    l = sys.stdin.read().strip().split('\n')
    out = []
    for line in l:
        a,b = list(map(int, line.split()))
        if b <= 1:
            print(a**b)
            continue
        lg = floor(log2(b))
        l = [a]*(lg+1)
        for i in range(lg):
            l[i+1]=l[i]**2
        # print(l)
        # 37 = 32 + 4 + 1 = 100101 there is bit j if n%(2**j) >= 2**(j-1)
        s = 1
        for j in range(lg, -1, -1):
            if b%(2**(j+1))>= 2**j:
                s*= l[j] 
                s%= 10**9+7
            # print(j, s)
        out.append(str(s))

    print('\n'.join(out))

main()

Test details

Test 1

Verdict:

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

correct output
1
0
0
0
0
...

user output
1
0
1
1
1
...

Feedback: Incorrect character on line 3 col 1: expected "0", got "1"

Test 2

Verdict:

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

correct output
276067146
838400234
148093882
546897305
467086232
...

user output
(empty)

Test 3

Verdict:

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

correct output
940305728
707431813
917260341
908974199
375947818
...

user output
(empty)