Accepted
Code
import math as mt
t=int(input())
for _ in range(t):
n,m=map(int,input().split())
a=min(n,m)
b=int(mt.sqrt(a))
ok=False
for i in range(2,b+1,1):
if(n%i==0 and m%i==0):
print(i)
ok=True
continue
if(ok):
continue
if(max(n,m)%a==0 and a!=1):
print(a)
continue
print(-1)
Information
- Submit By
- Type
- Submission
- Problem
- P1011 LCD
- Language
- Python 3 (Python 3.12.3)
- Submit At
- 2024-01-02 04:00:39
- Judged At
- 2024-11-11 03:44:40
- Judged By
- Score
- 100
- Total Time
- 1331ms
- Peak Memory
- 3.172 MiB