-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
62 lines (45 loc) · 1.02 KB
/
main.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def calcula(arr):
n1 = int(arr[0])
n2 = int(arr[1])
homens = geraMatriz(n1)
mata(n2, homens)
def geraMatriz(homens):
matriz = []
for x in range(homens):
matriz.append(False)
return matriz
def mata(num, homens):
contador = 1
volta = 0
while not restaUm(homens):
if(not homens[volta]):
if contador % num == 0:
homens[volta] = True
contador = contador + 1
volta = volta + 1
if volta + 1 == len(homens)+1:
volta = 0
for i in range(len(homens)):
if(not homens[i]):
global caseNumber
print('Case {}: {}'.format(caseNumber, i+1))
caseNumber = caseNumber + 1
def restaUm(homens):
resta = 0
for homem in range(len(homens)):
if(not homens[homem]):
resta = resta + 1
if(resta > 1):
return False
else:
return True
solutions = input()
cases = []
caseNumber = 1
for x in range(0, int(solutions)):
cases.append(input())
def separa(n):
return n.split()
x = list(map(separa, cases))
for y in range(0, len(x)):
calcula(x[y])