-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUntitled-8.py
More file actions
106 lines (83 loc) · 1.88 KB
/
Copy pathUntitled-8.py
File metadata and controls
106 lines (83 loc) · 1.88 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#%%
import numpy as np
N, M =map(int,input().split())
search = np.zeros(M+1)
for i in range(N):
K = list(map(int,input().split()))
for j in range(1,K[0]+1):
search[K[j]]+=1
place = np.where(search==N)
print(len(place[0]))
#%% [markdown]
# #### import numpy as np
# N, M =map(int,input().split())
# search = np.zeros(M)
# print(search)
#%%
import numpy as np
N, M =map(int,input().split())
search = np.zeros(M+1)
for i in range(N):
K = list(map(int,input().split()))
for j in range(1,K[0]+1):
search[K[j]]+=1
place = np.where(search==N)
print(search)
print(place)
print(len(place))
#%%
search = np.zeros(6)
search += 4
search[0]-=4
print(search)
place = np.where(search==N)
print(len(place[0]))
#%%
N, M = map(int,input().split())
listA = list(map(int,input().split()))
needM = [2,5,5,4,5,6,3,7,6]
listM = [needM[i-1] for i in listA]
print(listM)
#%%
listA = list(map(int,input().split()))
needM = [2,5,5,4,5,6,3,7,6]
listM = [needM[i-1] for i in listA]
print(listM)
#%%
import math
N,M = 20,4
# N, M = map(int,input().split())
# listA = list(map(int,input().split()))
# needM = [2,5,5,4,5,6,3,7,6]
# listM = [needM[i-1] for i in listA]
unique_list = sorted(list(set(listM)))
print(unique_list)
#%%
import math
N,M = 20,4
unique_list = sorted(list(set(listM)))
print(unique_list)
# ax+by+cz+...=A coeff=[a,b,c,...] ans=A
# if true ax+by+cz+...=A has integer answers
def HasAnswer(coefficients,ans):
if len(coefficients) == 1:
return coefficients[0] % ans == 0
else:
residue = ans % gcd_all(coefficients)
return residue == 0
#%%
import math
numberlist = [3,6]
def gcd_all(numberlist):
currentgcd = numberlist[0]
for i in numberlist[1:]:
#print(i)
currentgcd = math.gcd(currentgcd,i)
return currentgcd
#%%
for i in range(len(unique_list)):
HasAnswer(unique_list[:i+1])
#%%
gcd_all([3,6,5])
#%%
HasAnswer([3,5],4)