forked from Srinivas11789/AlgorithmNuggets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbet.py
More file actions
62 lines (45 loc) · 1.15 KB
/
bet.py
File metadata and controls
62 lines (45 loc) · 1.15 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
#!/bin/python
from __future__ import print_function
import os
import sys
#
# Complete the getTotalX function below.
#
def getTotalX(a, b):
#
# Write your code here.
#
# Find LCM
# prod = A number which is a factor of all the elements of a
# testcase 3 fails because max is assumed to be the lcm of the array, tc3 has 3 6 9 such that 6 is the LCM
prod = 1
#for num in a:
# prod *= num
prod = max(a)
# Find GCD
result = []
i = 1
curr = prod
while curr <= min(b):
factor = 1
for num in b:
if num%curr == 0:
factor = factor & 1
else:
factor = factor & 0
print (factor,curr)
if factor == 1:
result.append(curr)
i += 1
curr = prod * i
return len(result)
if __name__ == '__main__':
f = open(os.environ['OUTPUT_PATH'], 'w')
nm = raw_input().split()
n = int(nm[0])
m = int(nm[1])
a = map(int, raw_input().rstrip().split())
b = map(int, raw_input().rstrip().split())
total = getTotalX(a, b)
f.write(str(total) + '\n')
f.close()