Last active
October 20, 2015 11:47
-
-
Save whatalnk/5ec3d9d242099b5e532e to your computer and use it in GitHub Desktop.
TopCoder SRM 671 Div2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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