-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1028.py
More file actions
33 lines (27 loc) · 794 Bytes
/
1028.py
File metadata and controls
33 lines (27 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
problem: Collectable Cards
url: https://www.urionlinejudge.com.br/judge/en/problems/view/1028
"""
n_casos = int(input())
mdc_result = []
for i in range(n_casos):
pilhas_figuras = input()
pilhas_figuras = pilhas_figuras.split(' ')
pilhas_figuras[0] = int(pilhas_figuras[0])
pilhas_figuras[1] = int(pilhas_figuras[1])
# algoritmo de euclides para determinar mdc
if pilhas_figuras[0] < pilhas_figuras[1]:
divisor = pilhas_figuras[0]
dividendo = pilhas_figuras[1]
else:
divisor = pilhas_figuras[1]
dividendo = pilhas_figuras[0]
quociente = dividendo//divisor
resto = dividendo % divisor
while resto != 0:
dividendo = divisor
divisor = resto
resto = dividendo % divisor
mdc_result.append(divisor)
for mdc in mdc_result:
print(mdc)