随笔分类 -  ACM-USACO

摘要:Superprime RibButchering Farmer John's cows always yields the best prime rib. You can tell prime ribs by looking at the digits lovingly stamped across them, one by one, by FJ and the USDA. Farmer John ensures that a purchaser of his prime ribs gets really prime ribs because when sliced from the 阅读全文
posted @ 2012-08-29 22:05 mtry 阅读(493) 评论(0) 推荐(0)
摘要:Number TrianglesConsider the number triangle shown below. Write a program that calculates the highest sum of numbers that can be passed on a route that starts at the top and ends somewhere on the base. Each step can go either diagonally down to the left or diagonally down to the right. 7 ... 阅读全文
posted @ 2012-08-29 21:24 mtry 阅读(325) 评论(0) 推荐(0)
摘要:Prime PalindromesThe number 151 is a prime palindrome because it is both a prime number and a palindrome (it is the same number when read forward as backward). Write a program that finds all prime palindromes in the range of two supplied numbers a and b (5 <= a < b <= 100,000,000); both a a 阅读全文
posted @ 2012-08-29 21:20 mtry 阅读(1049) 评论(0) 推荐(0)
摘要:The ClocksIOI'94 - Day 2Consider nine clocks arranged in a 3x3 array thusly:|-------| |-------| |-------| | | | | | | | |---O | |---O | | O | | | | | | | |-------| |-------| |-------| A ... 阅读全文
posted @ 2012-08-29 10:51 mtry 阅读(441) 评论(0) 推荐(0)
摘要:Arithmetic ProgressionsAn arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+nb where n=0,1,2,3,... . For this problem, a is a non-negative integer and b is a positive integer.Write a program that finds all arithmetic progressions of length n in the set S of bisquares. The set of 阅读全文
posted @ 2012-08-28 21:03 mtry 阅读(278) 评论(0) 推荐(0)
摘要:Mother's MilkFarmer John has three milking buckets of capacity A, B, and C liters. Each of the numbers A, B, and C is an integer from 1 through 20, inclusive. Initially, buckets A and B are empty while bucket C is full of milk. Sometimes, FJ pours milk from one bucket to another until the second 阅读全文
posted @ 2012-08-28 15:46 mtry 阅读(553) 评论(0) 推荐(0)
摘要:Sorting a Three-Valued SequenceIOI'96 - Day 2Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted have at mostthreedifferent key values. This happens for instance when we sort medalists of a competition accord 阅读全文
posted @ 2012-08-27 20:31 mtry 阅读(350) 评论(0) 推荐(0)
摘要:Ordered FractionsConsider the set of all reduced fractions between 0 and 1 inclusive with denominators less than or equal to N.Here is the set when N = 5:0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1/1Write a program that, given an integer N between 1 and 160 inclusive, prints the fractions in order of 阅读全文
posted @ 2012-08-27 18:55 mtry 阅读(232) 评论(0) 推荐(0)
摘要:Packing RectanglesIOI 95The six basic layouts of four rectanglesFour rectangles are given. Find the smallest enclosing (new) rectangle into which these four may be fitted without overlapping. By smallest rectangle, we mean the one with the smallest area.All four rectangles should have their sides pa 阅读全文
posted @ 2012-08-27 18:46 mtry 阅读(601) 评论(0) 推荐(0)
摘要:Prime CryptarithmThe following cryptarithm is a multiplication problem that can be solved by substituting digits from a specified set of N digits into the positions marked with *. If the set of prime digits {2,3,5,7} is selected, the cryptarithm is called a PRIME CRYPTARITHM. * * * x * * ... 阅读全文
posted @ 2012-05-25 20:46 mtry 阅读(247) 评论(0) 推荐(0)
摘要:Calf FlacIt is said that if you give an infinite number of cows an infinite number of heavy-duty laptops (with very large keys), that they will ultimately produce all the world's great palindromes. Your job will be to detect these bovine beauties.Ignore punctuation, whitespace, numbers, and case 阅读全文
posted @ 2012-05-24 17:39 mtry 阅读(301) 评论(0) 推荐(0)