随笔分类 -  SRM145

摘要:同DIV1-600 阅读全文
posted @ 2013-11-25 06:43 valaxy 阅读(148) 评论(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 阅读(171) 评论(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 阅读(157) 评论(0) 推荐(0)
摘要:一道组合计数的问题,计算符合条件的合法组合个数。任意一个合法的path都不是精确的,因为landmarks可以被标记在多个点上。若将landmarks尽可能靠前匹配,path中将不存在任意前后两个相同高度的点A、B,其中B被标记而A没被标记,AB之间也不存在其他标记。否则可以标记A而去掉标记B来使得landmarks的标记情况更加“靠前”。因此题目所求变为计算这种精确的path的个数。使用一种分步策略来选择这种组合:令(d, h, i, tf) 表示d点高度为h,前i个landmarks已被标记,若tf=1:到达过山顶,否则:还没到到过山顶。地势可以升高、降低、不变,当前点可以被标记或者不标记 阅读全文
posted @ 2013-10-31 17:50 valaxy 阅读(198) 评论(0) 推荐(0)
摘要:有关vending machine (自动售货机) 的模拟题,需要吐槽的是:能够转的自动售货机?你找一个出来给我看看总之,虽然现在觉得意思明白,但是在写代码之前只觉得题目莫名其妙 1 class VendingMachine: 2 def motorUse(self, prices, purchases): 3 machine = Machine(prices) 4 lastBuyTime = 0 5 6 machine.moveToMaxPrice() 7 for i in range(0, len(pu... 阅读全文
posted @ 2013-10-29 03:50 valaxy 阅读(253) 评论(0) 推荐(0)
摘要:一般的编程题,注意计算份额的时候使用 int( 100 * x / sum ) 1 class Bonuses: 2 def getDivision(self, points): 3 pointSum = 0 4 for x in points: 5 pointSum += x 6 7 bounus = [] 8 bounusSum = 0 9 for x in points:10 bou = int(100 * x / pointSum)11 ... 阅读全文
posted @ 2013-10-28 23:33 valaxy 阅读(151) 评论(0) 推荐(0)