上一页 1 2 3 4 5 6 ··· 11 下一页
摘要: Air RaidTime Limit:1000MSMemory Limit:10000KTotal Submissions:6275Accepted:3756DescriptionConsider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an intersection and walking through town's streets you can never 阅读全文
posted @ 2014-02-25 20:57 ~~Snail~~ 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #define MAX_V 80 4 5 int V; //顶点数 6 int match[MAX_V]; //所匹配的顶点 7 bool used[MAX_V]; //DFS中用到 的访问标记 8 vector G[MAX_V]; //图的邻接表表示 9 10 //向图中增加一条边接u和v的边11 void add_edge(int u,int v)12 {13 G[u].push_back(v);14 G[v].push_ba... 阅读全文
posted @ 2014-02-25 09:34 ~~Snail~~ 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 #include 5 #define INF 0x7fffffff 6 #define MAX_V 210 7 8 using namespace std; 9 10 //用于表示边的结构体11 struct edge12 {13 int to; //终点14 int cap; //容量15 int rev; //反向边16 };17 18 int m,n;19 int iter[MAX_V]; //顶点到源咪的距离标号20 int level[MAX_V]; ... 阅读全文
posted @ 2014-02-25 09:28 ~~Snail~~ 阅读(180) 评论(0) 推荐(0) 编辑
摘要: Dividing coinsIt's commonly known that the Dutch have invented copper-wire. Two Dutch men were fighting over a nickel, which was made of copper. They were both so eager to get it and the fighting was so fierce, they stretched the coin to great length and thus created copper-wire.Not commonly kno 阅读全文
posted @ 2014-02-25 09:16 ~~Snail~~ 阅读(294) 评论(0) 推荐(0) 编辑
摘要: Optimal Array Multiplication SequenceGiven two arraysAandB, we can determine the arrayC=ABusing the standard definition of matrix multiplication:The number of columns in theAarray must be the same as the number of rows in theBarray. Notationally, let's say thatrows(A) andcolumns(A) are the numbe 阅读全文
posted @ 2014-02-25 07:48 ~~Snail~~ 阅读(191) 评论(0) 推荐(0) 编辑
摘要: Let Me Count The WaysAfter making a purchase at a large department store, Mel's change was 17 cents. He received 1 dime, 1 nickel, and 2 pennies. Later that day, he was shopping at a convenience store. Again his change was 17 cents. This time he received 2 nickels and 7 pennies. He began to wond 阅读全文
posted @ 2014-02-25 07:35 ~~Snail~~ 阅读(231) 评论(0) 推荐(0) 编辑
摘要: Goldbach's ConjectureIn 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the following conjecture:Every number greater than 2 can be written as the sum of three prime numbers.Goldbach cwas considering 1 as a primer number, a convention th 阅读全文
posted @ 2014-02-25 07:27 ~~Snail~~ 阅读(208) 评论(0) 推荐(0) 编辑
摘要: Error CorrectionA boolean matrix has theparity propertywhen each row and each column has an even sum, i.e. contains an even number of bits which are set. Here's a 4 x 4 matrix which has the parity property:1 0 1 00 0 0 01 1 1 10 1 0 1The sums of the rows are 2, 0, 4 and 2. The sums of the column 阅读全文
posted @ 2014-02-25 07:21 ~~Snail~~ 阅读(294) 评论(0) 推荐(0) 编辑
摘要: My T-shirt suits meOur friend Victor participates as an instructor in an environmental volunteer program. His boss asked Victor to distributeNT-shirts toMvolunteers, one T-shirt each volunteer, whereNis multiple of six, andNM. There are the same number of T-shirts of each one of the six available si 阅读全文
posted @ 2014-02-22 11:28 ~~Snail~~ 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 #define INF 0x7fffffff 5 #define MAX_V 210 6 7 using namespace std; 8 9 //用于表示边的结构体10 struct edge11 {12 int to; //终点13 int cap; //容量14 int rev; //反向边15 };16 17 int m,n;18 bool used[MAX_V]; //DFS中用到的访问标记19 vector G[MAX_V]; //用于保存图的邻接表,... 阅读全文
posted @ 2014-02-21 21:13 ~~Snail~~ 阅读(326) 评论(0) 推荐(0) 编辑
摘要: Drainage DitchesTime Limit:1000MSMemory Limit:10000KTotal Submissions:52160Accepted:19830DescriptionEvery time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to regrow. 阅读全文
posted @ 2014-02-21 20:59 ~~Snail~~ 阅读(201) 评论(0) 推荐(0) 编辑
摘要: Problem B: WarA war is being lead between two countries, A and B. As a loyal citizen of C, you decide to help your country’s espionage by attending the peace-talks taking place these days (incognito, of course). There are n people at the talks (not including you), but you do not know which person be 阅读全文
posted @ 2014-02-19 21:08 ~~Snail~~ 阅读(280) 评论(0) 推荐(0) 编辑
摘要: It's not a Bug, it's a Feature!It is a curious fact that consumers buying a new software product generally donotexpect the software to be bug-free. Can you imagine buying a car whose steering wheel only turns to the right? Or a CD-player that plays only CDs with country music on them? Probab 阅读全文
posted @ 2014-02-19 18:10 ~~Snail~~ 阅读(470) 评论(0) 推荐(0) 编辑
摘要: 1 #define MAX_N 10000 2 3 int par[MAX_N]; 4 5 //并查集初始化,初始化n个元素 6 void init(int n) 7 { 8 for(int i=0;i<n;i++) 9 par[i]=i;10 }11 12 //并查集查询操作,查询树的根13 int Find(int x)14 {15 if(par[x]==x)16 return x;17 return par[x]=Find(par[x]);18 }19 20 //并查集合并操作,合并x和y所属集合21 void Unite(... 阅读全文
posted @ 2014-02-19 08:42 ~~Snail~~ 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Floyd-Warshall算法用于求任意两点间的最短路问题 1 #define MAX_V 100 2 3 int d[MAX_V][MAX_V]; //d[u][v]表示边e=(u,v)的权值(不存在时设为INF,不过d[i][i]=0) 4 int V; //顶点数 5 6 int Min(int a,int b) 7 { 8 return a<b?a:b; 9 }10 11 void floyd_warshall()12 {13 for(int k=0;k<V;k++)14 for(int i=0;i<V;i++)15... 阅读全文
posted @ 2014-02-19 08:33 ~~Snail~~ 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Problem A: FrecklesIn an episode of the Dick Van Dyke show, little Richie connects the freckles on his Dad's back to form a picture of the Liberty Bell. Alas, one of the freckles turns out to be a scar, so his Ripley's engagement falls through.Consider Dick's back to be a plane with frec 阅读全文
posted @ 2014-02-19 08:23 ~~Snail~~ 阅读(274) 评论(0) 推荐(0) 编辑
摘要: Problem B: AudiophobiaConsider yourself lucky! Consider yourself lucky to be still breathing and having fun participating in this contest. But we apprehend that many of your descendants may not have this luxury. For, as you know, we are the dwellers of one of the most polluted cities on earth. Pollu 阅读全文
posted @ 2014-02-19 08:14 ~~Snail~~ 阅读(272) 评论(0) 推荐(0) 编辑
摘要: Question 1: Is Bigger Smarter?The ProblemSome people think that the bigger an elephant is, the smarter it is. To disprove this, you want to take the data on a collection of elephants and put as large a subset of this data as possible into a sequence so that the weights are increasing, but the IQ' 阅读全文
posted @ 2014-02-18 18:14 ~~Snail~~ 阅读(246) 评论(0) 推荐(0) 编辑
摘要: DollarsNew Zealand currency consists of $100, $50, $20, $10, and $5 notes and $2, $1, 50c, 20c, 10c and 5c coins. Write a program that will determine, for any given amount, in how many ways that amount may be made up. Changing the order of listing does not increase the count. Thus 20c may be made up 阅读全文
posted @ 2014-02-18 17:44 ~~Snail~~ 阅读(214) 评论(0) 推荐(0) 编辑
摘要: Problem E: VacationThe ProblemYou are planning to take some rest and to go out on vacation, but you really don't know which cities you should visit. So, you ask your parents for help. Your mother says"My son, you MUST visit Paris, Madrid, Lisboa and London. But it's only fun in this ord 阅读全文
posted @ 2014-02-18 17:29 ~~Snail~~ 阅读(133) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 11 下一页