Submission details
Task:Finding inverse
Sender:aalto26kh_009
Submission time:2026-11-12 20:38:11 +0200
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#10.07 sdetails
#20.07 sdetails
#30.07 sdetails
#40.08 sdetails
#50.07 sdetails
#60.07 sdetails
#70.07 sdetails
#80.07 sdetails
#90.07 sdetails
#100.07 sdetails
#110.07 sdetails
#120.07 sdetails
#130.07 sdetails
#140.07 sdetails

Code

# cook your dish here
"""
import math
import sys
for t in range(int(input())):
    a,b=map(int,input().split())
    print(pow(a, b, 10**9 + 7))
import math
"""
a,b=map(int,input().split())
g = math.gcd(a, b)
c=1
if c % g != 0:
    print(-1)
else:
    a, b, c = a // g, b // g, c // g
    x0 = (c * pow(a, -1, b)) % b
    y0 = (c - a * x0) // b
    print(x0)

Test details

Test 1

Verdict:

input
6 7

correct output
6

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?

Test 2

Verdict:

input
0 7

correct output
-1

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?

Test 3

Verdict:

input
5 78

correct output
47

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?

Test 4

Verdict:

input
89 99

correct output
89

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?

Test 5

Verdict:

input
0 61

correct output
-1

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?

Test 6

Verdict:

input
897 947

correct output
625

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?

Test 7

Verdict:

input
419 538

correct output
217

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?

Test 8

Verdict:

input
32 938

correct output
-1

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?

Test 9

Verdict:

input
184120 505187

correct output
438779

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?

Test 10

Verdict:

input
264601 885661

correct output
360221

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?

Test 11

Verdict:

input
40310 590135

correct output
-1

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?

Test 12

Verdict:

input
202254499 577081420

correct output
128866679

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?

Test 13

Verdict:

input
539836073 888851205

correct output
797044652

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?

Test 14

Verdict:

input
697847215 756971670

correct output
-1

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 11, in <module>
    g = math.gcd(a, b)
NameError: name 'math' is not defined. Did you mean: hash?