/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 19ms 3.062 MiB
#2 Accepted 2440ms 3.18 MiB
#3 Time Exceeded ≥3006ms ≥3.078 MiB

Code

def gcd(a, b):
 
  if a == 0:
    return b
  if b == 0:
    return a

  while a != b:
    if a > b:
      a = a - b
    else:
      b = b - a
  return a
def lcd(a, b):
  
  g = gcd(a, b)
  
  if g == 1:
    return -1
  
  for i in range(2, g + 1):
    if g % i == 0:
      return i

  return -1


t = int(input())

for _ in range(t):
  n, m = map(int, input().split())
  print(lcd(n, m))




Information

Submit By
Type
Submission
Problem
P1011 LCD
Language
Python 3 (Python 3.12.3)
Submit At
2024-01-01 07:42:16
Judged At
2024-11-11 03:44:45
Judged By
Score
50
Total Time
≥3006ms
Peak Memory
≥3.18 MiB