| Task: | Exponentiation |
| Sender: | aalto26kh_004 |
| Submission time: | 2026-11-11 20:05:41 +0200 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.07 s | details |
| #2 | ACCEPTED | 0.65 s | details |
| #3 | ACCEPTED | 0.61 s | details |
Code
from math import log2, ceil, floor
import sys
def main():
MOD = 10**9 + 7
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) %MOD
# 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%= MOD
# print(j, s)
out.append(str(s))
print('\n'.join(out))
main()Test details
Test 1
Verdict: WRONG ANSWER
| 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: 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 ... |
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 ... |
