jianupc

 

2013年7月20日

欧几里德算法

摘要: 欧几里德算法又叫辗转相除法,作用是求最大公约数//其核心方法是如果 a=q*b+r; 那么gcd(a,b) = gcd(b,r);int gcd(int a, int b) { if (b == 0)return a; return gcd(b, a % b);}扩展欧几里德算法:根据gcd(a,b) = xa + yb; 可以求出最大公约数gcd(a,b),x,y;根据辗转相除法: ri = qi+1 * ri+1 + ri+2; rk-1 = qk * rk;把上式改写 ri+2 = ri - qi+1 * ri+1;设rk = xi * ri-1 + yi * ... 阅读全文

posted @ 2013-07-20 22:37 shijianupc 阅读(240) 评论(0) 推荐(0) 编辑

2013年4月5日

线段树

摘要: 单点更新hdu1754 I Hate ItView Code #include <iostream>#include <cstdio>#include <cmath>using namespace std;#define lson l,m,root<<1#define rson m+1,r,root<<1|1const int MAX = 250000;int arr[MAX<<2];int n;void pushup(int root){ arr[root] = max(arr[root<<1],arr[ro 阅读全文

posted @ 2013-04-05 15:55 shijianupc 阅读(98) 评论(0) 推荐(0) 编辑

2013年3月22日

poj 1679 The Unique MST (次小生成树算法)

摘要: The Unique MSTTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 16309Accepted: 5652DescriptionGiven a connected undirected graph, tell if its minimum spanning tree is unique. Definition 1 (Spanning Tree): Consider a connected, undirected graph G = (V, E). A spanning tree of G is a subgraph of 阅读全文

posted @ 2013-03-22 17:50 shijianupc 阅读(181) 评论(0) 推荐(0) 编辑

2013年3月9日

poj 3026 Brog Maze(BFS+MST)

摘要: Borg MazeTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 6300Accepted: 2120DescriptionThe Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used to describe the group consciousness of the Borg civilization. Each B 阅读全文

posted @ 2013-03-09 15:09 shijianupc 阅读(155) 评论(0) 推荐(0) 编辑

2013年3月3日

poj 1002 487-3279

摘要: 487-3279Time Limit: 2000MSMemory Limit: 65536KTotal Submissions: 206132Accepted: 35976DescriptionBusinesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the University of Waterloo by d 阅读全文

posted @ 2013-03-03 21:20 shijianupc 阅读(137) 评论(0) 推荐(0) 编辑

2013年1月24日

poj 1860 Currency Exchange bellman-ford算法

摘要: Currency ExchangeTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 14644Accepted: 5050DescriptionSeveral currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There 阅读全文

posted @ 2013-01-24 20:11 shijianupc 阅读(173) 评论(0) 推荐(0) 编辑

2013年1月23日

poj 2263 Heavy Cargo floyd算法

摘要: Heavy CargoTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 2599Accepted: 1433DescriptionBig Johnsson Trucks Inc. is a company specialized in manufacturing big trucks. Their latest model, the Godzilla V12, is so big that the amount of cargo you can transport with it is never limited by the t 阅读全文

posted @ 2013-01-23 15:02 shijianupc 阅读(166) 评论(0) 推荐(0) 编辑

2013年1月22日

poj 1062 昂贵的聘礼 dijkstra算法

摘要: 昂贵的聘礼Time Limit: 1000MSMemory Limit: 10000KTotal Submissions: 29260Accepted: 8199Description年 轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿 不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要 5000金币就行了。"探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭司要他用金币来换,或者替他弄来其 阅读全文

posted @ 2013-01-22 22:47 shijianupc 阅读(287) 评论(0) 推荐(0) 编辑

poj 2387 Til the Cows Come Home dijkstra模板

摘要: Til the Cows Come HomeTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 22455Accepted: 7526DescriptionBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants 阅读全文

posted @ 2013-01-22 20:36 shijianupc 阅读(211) 评论(0) 推荐(0) 编辑

2013年1月21日

poj 1861 Network 最小生成树 kruskal

摘要: NetworkTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 10959Accepted: 4174Special JudgeDescriptionAndrew is working as system administrator and is planning to establish a new network in his company. There will be N hubs in the company, they can be connected to each other using cables. Since 阅读全文

posted @ 2013-01-21 21:01 shijianupc 阅读(166) 评论(0) 推荐(0) 编辑

导航