随笔分类 - USACO
都荒废好久了!
摘要:类型:枚举描述:Party LampsIOI 98To brighten up the gala dinner of the IOI'98 we have a set of N(10 <= N <= 100) colored lamps numbered from 1 to N.The lamps are connected to four buttons:Button 1: Whe...
阅读全文
摘要:Problem 57: Runaround NumbersRunaround numbers are integers with unique digits, none of which is zero (e.g., 81362) that also have an interesting property, exemplified by this demonstration: If you st...
阅读全文
摘要:Problem 38: Subset SumsFor many sets of consecutive integers from 1 through N (1 <= N <= 39), one can partition the set into two sets whose sums are identical. For example, if N=3, one can parti...
阅读全文
摘要:Problem 92: Preface NumberingA certain book's prefaces are numbered in upper case Roman numerals. Traditional Roman numeral values use a single letter to represent a certain subset of decimal numbers....
阅读全文
摘要:Problem 94: Hamming CodesRob Kolstad Given N, B, and D: Find a set of N codewords (1 <= N <= 64), each of length B bits (1 <= B <= 8), such that each of the codewords is at least Hamming d...
阅读全文
摘要:Type: tricky题目描述:Sorting a Three-Valued SequenceSorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted have at most...
阅读全文
摘要:很简单的一道题直接找出所有的分数,然后按值排序,去除重复的输出。my code标程一:改进:1.发现这些分数的分子和分母互素2.排序的时候的小技巧:p1/q1 = p2/q2 --> p1*q2 = p2*q1stand1标程二:改进:1.找出这些分数之间的规律,然后直接生成stand2
阅读全文
摘要:Type:无向图的连通分支描述:一个m*n的城堡,有一些墙分隔了若干房间,求房间数,及最大的房间,和拆掉一堵墙后能得到的最大房间。思路:先DFS,然后遍历m*n,根据最西边、最南边的规则,只考虑去掉东边北边的墙。Process:写的很垃圾,wa6次,刚开始“Choose the optimal wall to remove from the set of optimal walls b...
阅读全文
摘要:题目描述:n皇后问题,规模6-13,按顺序输出前三组解,再输出总解数。前一段学了点DLX的皮毛,就用它做了做,谁知道前三组解得输出顺序老出错。于是就放弃了。看了hint,就暴搜了一回,开了4个数组,记录行、列、'/','\',的放皇后的情况,根据对称性,搜一半就行了。my code看了解题报告,发现自己写的好烂,首先,不需要记录行(why?),其次,直接记录个数,标记是多余的。standard这个...
阅读全文
摘要:1.生成回文数 (100000000以内)大概20000个2.判断素数生成回文数的算法思想:分别生成数位是奇odd,和数位是偶even的回文数,对于串1234, 翻转一下 4321,再接上就生成了一个回文数 ,odd:1234321 even:12344321实现的方法可以多种多样。我用的是递归的方法。代码
阅读全文
摘要:这个题好久以前就看过了,但当时没思路,现在重新看,发现还是可以做的。思路:根据题目给出的六种layout,对每种的每个位置有4中选择(即4个矩形),另外4个矩形旋转后又可形成4个矩形。基本上是枚举所有的情况,然后找最小的面积值。最后一种layout,其实又要分四种情况的。代码
阅读全文
摘要:比较经典的3个杯子互相倒水的问题。状态即3个杯子中的水量,用一个3维数组记录,转移为六种组合。code
阅读全文
摘要:按步长递增的顺序搜索,先预处理出所有可能的步长,及位置值(用flg[]标记),再深搜预处理稍微有点麻烦code
阅读全文
摘要:USACO都荒废好久了,今年都没怎么做,今天突然想做做一道搜索题,写了个很**的算法,开了9维的数组保存状态,能写成这样也不容易啊,时间复杂度可想而知,因为用的广搜,空间就更。。。一看解题报告,太伤人了,居然有O(1)的算法!我的代码来看看解题报告吧:Analysis 58: The ClocksNotice that the order in which we apply moves is ir...
阅读全文

浙公网安备 33010602011771号