Knapsack Problems

摘要: Knapsack ProblemsPrerequisite modulesGreedyDynamic ProgrammingRecursive DescentSample Problem: Tape RecordingFarmer John's favorite hobby is creating a tape containing some of Bessie's favorite music to listen to while she's being milked. The amount of milk that Bessie produces is depend 阅读全文
posted @ 2013-08-29 16:14 makeecat 阅读(475) 评论(0) 推荐(0) 编辑

3.1.6 Stamps

摘要: StampsGiven a set of N stamp values (e.g., {1 cent, 3 cents}) and an upper limit K to the number of stamps that can fit on an envelope, calculate the largest unbroken list of postages from 1 cent to M cents that can be created.For example, consider stamps whose values are limited to 1 cent and 3 cen 阅读全文
posted @ 2013-08-29 16:07 makeecat 阅读(328) 评论(0) 推荐(0) 编辑

3.1.5 Contact

摘要: ContactIOI'98The cows have developed a new interest in scanning the universe outside their farm with radiotelescopes. Recently, they noticed a very curious microwave pulsing emission sent right from the centre of the galaxy. They wish to know if the emission is transmitted by some extraterrestri 阅读全文
posted @ 2013-08-29 16:06 makeecat 阅读(333) 评论(0) 推荐(0) 编辑

3.1.4 Shaping Regions

摘要: Shaping RegionsN opaque rectangles (1 #includeusing namespace std;#define MAX 10010int rx[MAX],ry[MAX],lx[MAX],ly[MAX],s[MAX],color[MAX],max,n,tot,i;void cut(int x1,int y1,int x2,int y2,int t){ while (t=rx[t] || x2=ry[t] || y2tot) {s[color[i]]+=abs((x1-x2)*(y1-y2));return;} if (x1=rx[t]){cut(r... 阅读全文
posted @ 2013-08-29 15:34 makeecat 阅读(242) 评论(0) 推荐(0) 编辑

3.1.3 Humble Numbers

摘要: Humble NumbersFor a given set of K prime numbers S = {p1, p2, ..., pK}, consider the set of all numbers whose prime factors are a subset of S. This set contains, for example, p1, p1p2, p1p1, and p1p2p3(among others). This is the set of `humble numbers' for the input set S. Note: The number 1 is 阅读全文
posted @ 2013-08-29 15:21 makeecat 阅读(260) 评论(0) 推荐(0) 编辑

3.1.2 Score Inflation

摘要: Score InflationThe more points students score in our contests, the happier we here at the USACO are. We try to design our contests so that people can score as many points as possible, and would like your assistance.We have several categories from which problems can be chosen, where a "category& 阅读全文
posted @ 2013-08-29 13:32 makeecat 阅读(250) 评论(0) 推荐(0) 编辑

3.1.1 Agri-Net

摘要: Agri-NetRuss CoxFarmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course.Farmer John ordered a high speed connection for his farm and is going to share his connectivity with the other farme 阅读全文
posted @ 2013-08-29 13:31 makeecat 阅读(251) 评论(0) 推荐(0) 编辑

Minimum Spanning Tree

摘要: Minimum Spanning TreeSample Problem: Agri-Net [Russ Cox, Winter 1999 USACO Open]Farmer John is bringing internet connectivity to all farms in the area. He has 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 min 阅读全文
posted @ 2013-08-29 13:21 makeecat 阅读(344) 评论(0) 推荐(0) 编辑

2.4.5 Fractions to Decimals

摘要: Fractions to Decimals Write a program that will accept a fraction of the form N/D, whereN is the numerator and D is the denominator and print the decimalrepresentation. If the decimal representation has a repeating sequenceof digits, indicate the sequence by enclosing it in brackets. For example,1.. 阅读全文
posted @ 2013-08-22 13:01 makeecat 阅读(247) 评论(0) 推荐(0) 编辑

2.4.4 Bessie Come Home

摘要: Bessie Come HomeKolstad & BurchIt's dinner time, and the cows are out in their separate pastures.Farmer John rings the bell so they will start walking to the barn. Yourjob is to figure out which one cow gets to the barn first (the suppliedtest data will always have exactly one fastest cow).B 阅读全文
posted @ 2013-08-22 12:57 makeecat 阅读(255) 评论(0) 推荐(0) 编辑