USACO
文章平均质量分 88
--Simone-
这个作者很懒,什么都没留下…
展开
-
Spinning Wheels(暴力)
nment mark (at 0 degrees) so that the wheels can all be started in a known position. Wheels rotate in the `plus degrees' direction, so that shortly after they start, they pass through 1 degree, 2 degrees, etc. (though probably not at the same time).This原创 2014-08-18 10:00:52 · 110 阅读 · 0 评论 -
Cow Tours(最短路 + Floyd)
that cannot be connected by any sequence of cow paths, thus partitioning Farmer John's farm into multiple fields.Farmer John would like add a single a cow path between one pair of pastures using the constraints below.A field's `diameter' is defined to原创 2014-03-25 21:03:51 · 65 阅读 · 0 评论 -
Bessie Come Home(最短路 + Floyd)
hich one cow gets to the barn first (the supplied test data will always have exactly one fastest cow).Between milkings, each cow is located in her own pasture, though some pastures have no cows in them. Each pasture is connected by a path to one or more原创 2014-03-25 18:02:37 · 150 阅读 · 0 评论 -
Overfencing(BFS)
maze. Even more happily, the maze he created by this overfencing experience is a `perfect' maze: you can find a way out of the maze from any point inside it.Given W (1 <= W <= 38), the width of the maze; H (1 <= H <= 100), th原创 2014-03-25 16:29:29 · 85 阅读 · 0 评论 -
Controlling Companies(DFS + 邻接矩阵)
company A controls company B if at least one of the following conditions is satisfied:Company A = Company BCompany A owns more than 50% of Company BCompany A controls K (K >= 1) companies denoted C1, ..., CK with each company Ci owning xi% o原创 2014-03-01 19:08:25 · 94 阅读 · 0 评论 -
Money Systems(DP)
ionally, coins come in values like 1, 5, 10, 20 or 25, 50, and 100 units, sometimes with a 2 unit coin thrown in for good measure.The cows want to know how many different ways it is possible to dispense a certain amount of money using various coin system原创 2014-02-26 19:59:48 · 107 阅读 · 0 评论 -
Zero Sum(DFS)
gits together between each pair of digits (not in front of the first digit). Calculate the result that of the expression and see if you get zero.Write a program that will find all sequences of length N that produce a zero sum.PROGRAM NAME: zerosumINP原创 2014-02-25 20:09:16 · 118 阅读 · 0 评论 -
Cow Pedigrees(DP)
s can easily be represented by one or more binary trees with a total of N (3 <= N < 200) nodes. The trees have these properties:The degree of each node is 0 or 2. The degree is the count of the node's immediate children.The height of the原创 2014-02-25 18:59:30 · 64 阅读 · 0 评论 -
Longest Prefix(字典树 + DFS + 剪枝)
decomposing a long sequence into shorter sequences called primitives.We say that a sequence S can be composed from a given set of primitives P if there is a some sequence of (possibly repeated) primitives from the set whose concatenation equals S. Not ne原创 2014-02-24 21:08:36 · 86 阅读 · 0 评论 -
Runaround Numbers(枚举)
the left digit (8 in our number) and count that number of digits to the right (wrapping back to the first digit when no digits on the right are available), you'll end up at a new digit (a number which does not end up at a new digit is not a Runaround Numbe原创 2014-02-18 17:08:43 · 114 阅读 · 0 评论 -
Subset Sums(DP)
n the set {1, 2, 3} in one way so that the sums of both subsets are identical:{3} and {1,2}This counts as a single partitioning (i.e., reversing the order counts as the same partitioning and thus does not increase the count of partitions).If N=7, t原创 2014-02-18 14:10:20 · 83 阅读 · 0 评论 -
The Tamworth Two(技巧模拟)
akes place on a 10 by 10 planar grid. Squares can be empty or they can contain:an obstacle,the cows (who always travel together), orFarmer John.The cows and Farmer John can occupy the same square (when they `meet') but neither the cows nor Farmer原创 2014-03-26 21:26:55 · 94 阅读 · 0 评论 -
Fractions to Decimals(模拟)
on has a repeating sequence of digits, indicate the sequence by enclosing it in brackets. For example, 1/3 = .33333333...is denoted as 0.(3), and 41/333 = 0.123123123...is denoted as 0.(123). Use xxx.0 to denote an integer. Typical conversions are:1/3原创 2014-03-28 19:15:10 · 96 阅读 · 0 评论 -
Feed Ratios(暴力)
ese easily mixable grains, he can not buy that mixture! He buys three other mixtures of the three grains and then combines them to form the perfect mixture.Given a set of integer ratios barley:oats:wheat, find a way to combine them IN INTEGER MULTIPLES t原创 2014-08-17 17:19:35 · 91 阅读 · 0 评论 -
Magic Squares(BFS + string)
65In this task we consider the version where each square has a different color. Colors are denoted by the first 8 positive integers. A sheet configuration is given by the sequence of colors obtained by reading the colors of the squares starting a原创 2014-08-17 15:58:43 · 66 阅读 · 0 评论 -
Sweet Butter(最短路 + Dijstra)
<= N <= 500) cows will lick it and thus will produce super-sweet butter which can be marketed at better prices. Of course, he spends the extra money on luxuries for the cows.FJ is a sly farmer. Like Pavlov of old, he knows he can train the原创 2014-08-13 23:07:46 · 76 阅读 · 0 评论 -
Stringsobits(DP)
ntains all possible strings of length N that have L (1 <= L <= N) or fewer bits that are `1'.Your task is to read a number I (1 <= I <= sizeof(S)) from the input and print the Ith element of the ordered set for N bits with no原创 2014-08-13 17:08:14 · 50 阅读 · 0 评论 -
Factorials(数学)
nteger on most computers, and 70! is too large for most floating-point variables. Your task is to find the rightmost non-zero digit of n!. For example, 5! = 1 * 2 * 3 * 4 * 5 = 120, so the rightmost non-zero digit of 5! is 2. Likewise, 7! = 1 * 2 * 3 * 4 *原创 2014-08-12 23:23:45 · 92 阅读 · 0 评论 -
Contact(map + 暴搜)
rom the centre of the galaxy. They wish to know if the emission is transmitted by some extraterrestrial form of intelligent life or if it is nothing but the usual heartbeat of the stars.Help the cows to find the Truth by providing a tool to analyze bit p原创 2014-08-06 23:19:04 · 2629 阅读 · 0 评论 -
Stamps(DP)
o M cents that can be created.For example, consider stamps whose values are limited to 1 cent and 3 cents; you can use at most 5 stamps. It's easy to see how to assemble postage of 1 through 5 cents (just use that many 1 cent stamps), and successive valu原创 2014-08-06 15:32:46 · 93 阅读 · 0 评论 -
Humble Numbers(技巧)
p2p3 (among others). This is the set of `humble numbers' for the input set S. Note: The number 1 is explicitly declared not to be a humble number.Your job is to find the Nth humble number for a given set S. Long integers (signed 32-bit) will be adequate原创 2014-05-23 15:22:58 · 85 阅读 · 0 评论 -
Score Inflation(完全背包)
e your assistance.We have several categories from which problems can be chosen, where a "category" is an unlimited set of contest problems which all require the same amount of time to solve and deserve the same number of points for a correct so原创 2014-04-06 21:13:27 · 81 阅读 · 0 评论 -
Agri-Net(最小生成树 + 并查集)
hn ordered a high speed connection for his farm and is going to share his connectivity with the other farmers. To minimize cost, he wants to lay the minimum amount of optical fiber to connect his farm to all the other farms.Given a list of how much fiber原创 2014-03-30 22:01:45 · 75 阅读 · 0 评论 -
Party Lamps(分析 + 模拟)
on 1: When this button is pressed, all the lamps change their state: those that are ON are turned OFF and those that are OFF are turned ON.Button 2: Changes the state of all the odd numbered lamps.Button 3: Changes the state of all the even numbered la原创 2014-02-17 20:29:08 · 107 阅读 · 0 评论 -
Preface Numbering(暴搜)
the standard set: I 1 L 50 M 1000 V 5 C 100 X 10 D 500As many as three of the same marks that represent 10n may be placed consecutively to form other numbers:III is 3CCC is 300Marks that have原创 2014-02-17 13:53:24 · 55 阅读 · 0 评论 -
Calf Flac(枚举)
omes. Your job will be to detect these bovine beauties.Ignore punctuation, whitespace, numbers, and case when testing for palindromes, but keep these extra characters around so that you can print them out as the answer; just consider the letters `A-Z' an原创 2013-08-05 02:19:51 · 68 阅读 · 0 评论 -
Barn Repair(贪心)
full.The cows spend the night in stalls that are arranged adjacent to each other in a long line. Some stalls have cows in them; some do not. All stalls are the same width.Farmer John must quickly erect new boards in front of the stalls, since the doors原创 2013-08-04 14:42:38 · 56 阅读 · 0 评论 -
Mixing Milk(贪心)
he cheapest possible manner.The Merry Milk Makers company has several farmers from which they may buy milk, and each one has a (potentially) different price at which they sell to the milk packing plant. Moreover, as a cow can only produce so much milk a原创 2013-08-01 15:03:03 · 92 阅读 · 0 评论 -
iDual Palindromes(枚举)
2321 is a palindrome; the number 77778 is not. Of course, palindromes have neither leading nor trailing zeroes, so 0220 is not a palindrome.The number 21 (base 10) is not palindrome in base 10, but the number 21 (base 10) is, in fact, a palindrome in bas原创 2013-08-01 01:39:41 · 50 阅读 · 0 评论 -
Palindromic Squares(枚举)
all the integers N (1 <= N <= 300 base 10) such that the square of N is palindromic when expressed in base B; also print the value of that palindromic square. Use the letters 'A', 'B', and so on to represent the digits 10, 11, and so on.Pr原创 2013-07-31 17:32:19 · 54 阅读 · 0 评论 -
Name That Number(模拟)
s filing system, though, and wish to call the members of their herd by a pleasing name rather than saying, "C'mon, #4734, get along."Help the poor cowhands out by writing a program that will translate the brand serial number of a cow into possi原创 2013-07-31 11:38:32 · 79 阅读 · 0 评论 -
Transformations(枚举)
ation that has been applied to the original pattern given the following list of possible transformations:#1: 90 Degree Rotation: The pattern was rotated clockwise 90 degrees.#2: 180 Degree Rotation: The pattern was rotated clockwise 180 degrees.#3:原创 2013-07-28 13:23:01 · 53 阅读 · 0 评论 -
Milking Cows(模拟)
000. The second farmer begins at time 700 and ends at time 1200. The third farmer begins at time 1500 and ends at time 2100. The longest continuous time during which at least one farmer was milking a cow was 900 seconds (from 300 to 1200). The longest time原创 2013-07-28 12:48:33 · 198 阅读 · 0 评论 -
Broken Necklace(模拟)
1 2 1 2 r b b r b r r b r b b b r r b r r r原创 2013-07-26 13:53:57 · 73 阅读 · 0 评论 -
Friday the Thirteenth(模拟)
program that will compute the frequency that the 13th of each month lands on Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday over a given period of N years. The time period to test will be from January 1, 1900 to December 31, 1900+N-1 f2013-07-25 00:28:20 · 88 阅读 · 0 评论 -
Prime Cryptarithm(枚举)
me digits {2,3,5,7} is selected, the cryptarithm is called a PRIME CRYPTARITHM. * * * x * * ------- * * * <-- partial product 1 * * * <-- partial product 2 ------- * * * *Digits c原创 2013-08-05 13:15:19 · 52 阅读 · 0 评论 -
The Clocks(DFS)
| | | | | | |-------| |-------| |-------| A B C|-------| |-------| |-------|| | | | | || O | | O | | O || | |原创 2013-12-19 10:23:04 · 69 阅读 · 0 评论 -
The Castle(DFS + 枚举)
nly the winning number for the lottery! Farmer John won a fabulous castle in the Irish countryside.Bragging rights being what they are in Wisconsin, Farmer John wished to tell his cows all about the castle. He wanted to know how many rooms it has and how原创 2014-02-12 19:13:22 · 79 阅读 · 0 评论 -
Hamming Codes(二进制枚举)
of D (1 <= D <= 7) away from each of the other codewords. The Hamming distance between a pair of codewords is the number of binary bits that differ in their binary notation. Consider the two codewords 0x554 and 0x234 and their differences (0x原创 2014-02-12 00:47:20 · 74 阅读 · 0 评论 -
Healthy Holsteins(二进制枚举)
daily vitamin requirement for the cows. Help Farmer John feed his cows so they stay healthy while minimizing the number of scoops that a cow is fed.Given the daily requirements of each kind of vitamin that a cow needs, identify the smallest combination o原创 2014-02-11 19:34:41 · 59 阅读 · 0 评论