| Task: | Finding inverse |
| Sender: | aalto26kh_004 |
| Submission time: | 2026-11-12 03:02:13 +0200 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | details |
| #2 | ACCEPTED | 0.04 s | details |
| #3 | RUNTIME ERROR | 0.06 s | details |
| #4 | RUNTIME ERROR | 0.06 s | details |
| #5 | ACCEPTED | 0.04 s | details |
| #6 | ACCEPTED | 0.04 s | details |
| #7 | RUNTIME ERROR | 0.06 s | details |
| #8 | ACCEPTED | 0.04 s | details |
| #9 | ACCEPTED | 0.04 s | details |
| #10 | RUNTIME ERROR | 0.06 s | details |
| #11 | ACCEPTED | 0.04 s | details |
| #12 | RUNTIME ERROR | 0.06 s | details |
| #13 | RUNTIME ERROR | 0.06 s | details |
| #14 | ACCEPTED | 0.04 s | details |
Code
from math import gcd
def main():
a, m = map(int, input().split())
if gcd(a,m ) != 1:
print(-1)
else:
phi = 1
for x in range(2, int(m**(1/2))+1):
c = 0
while m%x == 0:
c += 1
m /= x
if c != 0:
phi *= x**(c-1)*(x-1)
if m > 1 :
phi *= (m-1)
print(pow(a, phi-1, m))
main()Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 6 7 |
| correct output |
|---|
| 6 |
| user output |
|---|
| 6 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 0 7 |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 3
Verdict: RUNTIME ERROR
| input |
|---|
| 5 78 |
| correct output |
|---|
| 47 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 20, in <module>
main()
File "/box/input/code.py", line 18, in main
print(pow(a, phi-1, m))
TypeError: operands do not support pow()Test 4
Verdict: RUNTIME ERROR
| input |
|---|
| 89 99 |
| correct output |
|---|
| 89 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 20, in <module>
main()
File "/box/input/code.py", line 18, in main
print(pow(a, phi-1, m))
TypeError: operands do not support pow()Test 5
Verdict: ACCEPTED
| input |
|---|
| 0 61 |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 897 947 |
| correct output |
|---|
| 625 |
| user output |
|---|
| 625 |
Test 7
Verdict: RUNTIME ERROR
| input |
|---|
| 419 538 |
| correct output |
|---|
| 217 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 20, in <module>
main()
File "/box/input/code.py", line 18, in main
print(pow(a, phi-1, m))
TypeError: operands do not support pow()Test 8
Verdict: ACCEPTED
| input |
|---|
| 32 938 |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 184120 505187 |
| correct output |
|---|
| 438779 |
| user output |
|---|
| 438779 |
Test 10
Verdict: RUNTIME ERROR
| input |
|---|
| 264601 885661 |
| correct output |
|---|
| 360221 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 20, in <module>
main()
File "/box/input/code.py", line 18, in main
print(pow(a, phi-1, m))
TypeError: operands do not support pow()Test 11
Verdict: ACCEPTED
| input |
|---|
| 40310 590135 |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 12
Verdict: RUNTIME ERROR
| input |
|---|
| 202254499 577081420 |
| correct output |
|---|
| 128866679 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 20, in <module>
main()
File "/box/input/code.py", line 18, in main
print(pow(a, phi-1, m))
TypeError: operands do not support pow()Test 13
Verdict: RUNTIME ERROR
| input |
|---|
| 539836073 888851205 |
| correct output |
|---|
| 797044652 |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 20, in <module>
main()
File "/box/input/code.py", line 18, in main
print(pow(a, phi-1, m))
TypeError: operands do not support pow()Test 14
Verdict: ACCEPTED
| input |
|---|
| 697847215 756971670 |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
