Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
TopCoder SRM 671 Div2
# SRM 671 Div2 Easy
# [Very short Editorial of SRM #671 - Codeforces](
class BearPaints():
def maxArea(self, w, h, m):
area = 1
for i in range(1,w+1):
area = max(area, i * min(m/i, h))
return area
# SRM 671 Div2 Easy
import collections
import bisect
class BearDartsDiv2():
def count(self, w):
dic = collections.defaultdict(list)
size = len(w)
for a in range(size):
for b in range(a + 1, size):
dic[w[a] * w[b]].append(b)
for k in dic:
dic[k] = sorted(dic[k])
ans = 0
for c in range(2, size):
for d in range(c + 1, size):
if w[d] % w[c]:
if dic[w[d] // w[c]]:
ans += bisect.bisect_left(dic[w[d] // w[c]], c)
return ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.