You are viewing a single comment's thread. Return to all comments →
Hi there. I'm a beginner in Python. I don't know too much about complexity. Below is my solution in Python 2. Is my way efficient? Thank you!
#!/bin/python import sys n,m = map(int,raw_input().strip().split(' ')) a = map(int,raw_input().strip().split(' ')) b = map(int,raw_input().strip().split(' ')) final = 0 lower,upper = max(a),min(b) for i in xrange(lower,upper+1): if sum(1 for k in a if i%k == 0) == n and sum(1 for k in b if k%i == 0) == m: final += 1 print final
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →
Hi there. I'm a beginner in Python. I don't know too much about complexity. Below is my solution in Python 2. Is my way efficient? Thank you!