摘要:
同 DIV1-300 阅读全文
posted @ 2013-11-25 07:40
valaxy
阅读(107)
评论(0)
推荐(0)
摘要:
一般编程题 1 class YahtzeeScore: 2 def maxPoints(self, toss): 3 count = [0] * 7 4 for x in toss: 5 count[x] += 1 6 result = -1 7 for i in range(1, 7): 8 result = max(result, i * count[i]) 9 return result10 11 # test12 o = YahtzeeScore()1... 阅读全文
posted @ 2013-11-25 07:35
valaxy
阅读(116)
评论(0)
推荐(0)
摘要:
同DIV1-600 阅读全文
posted @ 2013-11-25 06:43
valaxy
阅读(147)
评论(0)
推荐(0)
摘要:
枚举题,原题重新表述为:求 \(\{\frac{100x}{time} \ | \ x \in (0,time)\}\) 集合内整数的个数\(time\) 的范围不算大,直接枚举即可优化\(整数个数=gcd(time,100)-1\)证明如下:\(\frac{100x}{time}\) 是整数当且仅当 \(x=k \times \frac{time}{gcd(time,100)}, k \in Z \),则:\(\begin{equation}\begin{split}x &\in (0, time) \\ k \times \frac{time}{gcd(time,100)} &am 阅读全文
posted @ 2013-11-25 06:34
valaxy
阅读(168)
评论(0)
推荐(0)
摘要:
一般编程题,但是题目的叙述方式真的好奇怪 1 class ImageDithering: 2 def count(self, dithered, screen): 3 counter = 0 4 for line in screen: 5 for ch in line: 6 if ch in dithered: 7 counter += 1 8 return counter 9 10 11 # test12 o = ImageDithering... 阅读全文
posted @ 2013-11-25 05:58
valaxy
阅读(156)
评论(0)
推荐(0)
摘要:
图论题,题目重新叙述为:一棵树从根出发遍历完所有节点的最短总路径之和令 \(p(x)\) 表示节点 \(x\) 到根的路径长,\(sum\) 表示所求总路径之和,则:\(sum_{min}=2 \times \sum_i ductLength_i - max\{p(x)\}\)证明最优解与深度优先遍历有关,先证明如下问题:若最终遍历还要回到根节点,则最短路径之和 \(sum2_{min}\) 就是深度优先遍历的路径之和 \(deepsum\)利用归纳法可以证明深度优先遍历路径和\(deepsum=2 \times \sum_i ductLength_i\)若最终遍历回到根节点,则任何一条边必然 阅读全文
posted @ 2013-11-25 02:09
valaxy
阅读(166)
评论(0)
推荐(0)
摘要:
同DIV1-300 阅读全文
posted @ 2013-11-25 02:06
valaxy
阅读(141)
评论(0)
推荐(0)
摘要:
一般编程题 1 class Time: 2 def whatTime(self, seconds): 3 h = seconds // 3600 4 m = seconds % 3600 // 60 5 s = seconds % 60 6 return "%s:%s:%s" % (h, m, s) 7 8 # test 9 o = Time()10 11 # test case12 assert(o.whatTime(0) == "0:0:0")13 assert(o.whatTime(3661) == "1:1:1"... 阅读全文
posted @ 2013-11-25 02:03
valaxy
阅读(116)
评论(0)
推荐(0)
摘要:
枚举题,由于 \(A\) 和 \(B\) 是原数的比例,将原题重新叙述为:已知集合 \(A\) 和 \(B\),\(k_1A\) 和 \(k_2B\) 是 \(A\)、\(B\) 分别乘以 \(k_1\)、\(k_2\) 的数组。找到一组 \((k_1, k_2)\) 使得\(k_1A\) 和 \(k_2B\) 中不相同的数尽可能少,找到这个最小的数\(k_1, k_2\) 无上限,不可能枚举所有的 \(k_1, k_2\)最优情况下必然存在数 \((a, b) \in (A, B)\) 使得 \(k_1a=k_2b\),或者不存在则最优解直接为 \(len(A)+len(B)\)。可令 \( 阅读全文
posted @ 2013-11-25 00:12
valaxy
阅读(164)
评论(0)
推荐(0)
浙公网安备 33010602011771号