/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 14ms 3.059 MiB
#2 Accepted 1759ms 3.141 MiB
#3 Time Exceeded ≥3099ms ≥3.062 MiB

Code

t = int(input())

for i in range(t):
	n,m = map(int, input().split())
	if n <= m:
		mi = n
	else:
		mi = m
	
	lcd = -1
	
	if n == 1 or m == 1:
		lcd = -1
	elif m == n:
		lcd = m
	elif n<=1 or m<=1:
		lcd = -1
		
	else:
		k = 2
		
	
		for _ in range(mi):
			if m % k == 0 and n % k == 0:
				lcd = k
				break
			
			k = k+1
			
			

	print(lcd)
		
	

Information

Submit By
Type
Submission
Problem
P1011 LCD
Contest
Brain booster - 1
Language
Python 3 (Python 3.12.3)
Submit At
2023-12-31 17:03:48
Judged At
2024-11-11 03:44:51
Judged By
Score
50
Total Time
≥3099ms
Peak Memory
≥3.141 MiB