Flood Fill

摘要: Flood Fill Sample Problem: Connected FieldsFarmer John's fields are broken into fields, with paths between some of them. Unfortunately, some fields are not reachable from other fields via the paths.Define a superfield is a collection of fields that are all reachable from each other. Calculate th 阅读全文
posted @ 2013-08-22 11:54 makeecat 阅读(212) 评论(0) 推荐(0) 编辑

Graph Theory

摘要: Graph Theory What's a Graph?Formally, a graph is the following:a collection of vertices V, anda collection of edges E consisting of pairs of vertices.Think of vertices as ``locations''. The set of vertices is the set of all the possible locations. In this analogy, edges represent paths b 阅读全文
posted @ 2013-08-22 11:53 makeecat 阅读(227) 评论(0) 推荐(0) 编辑

1.5.4 Checker Challenge

摘要: Checker ChallengeExamine the 6x6 checkerboard below and note that the six checkers are arranged on the board so that one and only one is placed in each row and each column, and there is never more than one in any diagonal. (Diagonals run from southeast to northwest and southwest to northeast and inc 阅读全文
posted @ 2013-08-22 11:52 makeecat 阅读(175) 评论(0) 推荐(0) 编辑

1.5.3 Superprime Rib

摘要: 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 @ 2013-08-22 11:51 makeecat 阅读(238) 评论(0) 推荐(0) 编辑

1.5.2 Prime Palindromes

摘要: 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 =1 do begin s:=s+s[j]; ... 阅读全文
posted @ 2013-08-22 11:50 makeecat 阅读(202) 评论(0) 推荐(0) 编辑

1.5.1 Number Triangles

摘要: 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 @ 2013-08-22 11:49 makeecat 阅读(165) 评论(0) 推荐(0) 编辑

Binary Numbers

摘要: Binary Numbers Representing Binary NumbersComputers operate on 1's and 0's; these are called 'bits'. A byte is a group of 8 bits, like this: 00110101. A computer word on my computer ('int') is 4 bytes, 32 bits: 10011010110101011010001010101011. Other computers have different 阅读全文
posted @ 2013-08-22 11:48 makeecat 阅读(333) 评论(0) 推荐(0) 编辑

1.4.4 Mother's Milk

摘要: Mother's Milk Farmer 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 fullof milk. Sometimes, FJ pours milk from one bucket to another until thesecond bu 阅读全文
posted @ 2013-08-22 11:46 makeecat 阅读(180) 评论(0) 推荐(0) 编辑

1.4.3 Arithmetic Progressions

摘要: Arithmetic Progressions An 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 anon-negative integer and b is a positive integer. Write a program that finds all arithmetic progressions of lengthn in the set S of bisquares. The set of . 阅读全文
posted @ 2013-08-22 11:45 makeecat 阅读(287) 评论(0) 推荐(0) 编辑

1.4.2 The Clocks

摘要: The ClocksIOI'94 - Day 2Consider nine clocks arranged in a 3x3 array thusly:|-------| |-------| |-------| | | | | | | | |---O | |---O | | O | | | | | | | |-------| |-------| |-------| A ... 阅读全文
posted @ 2013-08-22 11:44 makeecat 阅读(245) 评论(0) 推荐(0) 编辑