Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active October 20, 2015 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/5ec3d9d242099b5e532e to your computer and use it in GitHub Desktop.
Save whatalnk/5ec3d9d242099b5e532e to your computer and use it in GitHub Desktop.
TopCoder SRM 671 Div2
# SRM 671 Div2 Easy
# [Very short Editorial of SRM #671 - Codeforces](http://codeforces.com/blog/entry/20939)
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]:
continue
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