Task: | Exponentiation |
Sender: | esya_rae |
Submission time: | 2024-11-18 11:48:11 +0200 |
Language: | Python3 (PyPy3) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.09 s | details |
#2 | ACCEPTED | 0.30 s | details |
#3 | ACCEPTED | 0.25 s | details |
Code
import syssys.setrecursionlimit(10**6)input = sys.stdin.readlinemod = 10**9+7def fast_exp(a, b):if b == 0:return 1g = 1while b > 1:if b % 2 == 1:g = (g * a) % modb -= 1a = (a * a) % modb //= 2return (a * g) % modn = int(input())for i in range(n):a, b = map(int, input().split())print(fast_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 |