2011年7月21日

最短路径:Dijkstra——初探

摘要: //算法:Dijkstra//主要思想(贪心):将图分为两部分:已确定离源点s最短距离的节点集合Q与未确定的集合P;//初始化:将dist[s]=0;visted[s]=1;//循环:在未确定集合P中寻找离源点最短距离的节点,并且然后对于其余未确定的节点进行松弛;//终止:visted中的所有元素均为1//算法正确性的简单证明(数学归纳)://1,当n=1时,即确定的集合中元素只有源点s时,显然是集合中的元素离源点都是最短的;//2,假设当n=k时即确定最短路径的集合中元素个数为k,结论正确;//那么n=k+1时即加入的第k+1个元素g是未确定最短路径的集合P中离源点最近的;//若此时dist 阅读全文

posted @ 2011-07-21 12:11 sleeper_qp 阅读(219) 评论(0) 推荐(0) 编辑

soj 2222 Health Power

摘要: 2222 Health Powerxy likes playing TV games,these days there comes up aproblem,that is,as you know,in the game,he can get plenty offoods,which can add to the HP (Health Power) of the role, only whenthe HP grows full,it adds to the Score of the role, now he doesn'thow to maxium the Score of when f 阅读全文

posted @ 2011-07-21 12:10 sleeper_qp 阅读(311) 评论(0) 推荐(0) 编辑

soj 2749 The Fewest Coins

摘要: DescriptionFarmer John has gone to town to buy some farm supplies. Being a very efficient man, he always pays for his goods in such a way that the smallest number of coins changes hands, i.e., the number of coins he uses to pay plus the number of coins he receives in change is minimized. Help him to 阅读全文

posted @ 2011-07-21 12:09 sleeper_qp 阅读(435) 评论(0) 推荐(1) 编辑

poj 1837 很不错的题

摘要: BalanceTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 5258Accepted: 3120DescriptionGigel has a strange"balance" and he wants to poise it. Actually, the device isdifferent from any other ordinary balance.It orders two arms of negligible weight and each arm's length is15. Some 阅读全文

posted @ 2011-07-21 12:08 sleeper_qp 阅读(236) 评论(0) 推荐(0) 编辑

poj 2184 Cow Exhibition

摘要: Cow ExhibitionTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 5834Accepted: 1945Description"Fat and docile, bigand dumb, they look so stupid, they aren't muchfun..."- Cows with Guns by Dana LyonsThe cows want to prove to the public that they are both smart andfun. In order to 阅读全文

posted @ 2011-07-21 12:07 sleeper_qp 阅读(457) 评论(0) 推荐(0) 编辑

poj 2955 Brackets

摘要: BracketsTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 1734Accepted: 869DescriptionWe give the followinginductive definition of a “regular brackets” sequence:the empty sequence is a regular brackets sequence,if s is a regular brackets sequence, then (s) and[s] are regular brackets sequence 阅读全文

posted @ 2011-07-21 12:06 sleeper_qp 阅读(359) 评论(0) 推荐(0) 编辑

Ecust 406 sleeping at work

摘要: #include <stdio.h>#include <memory.h>int f[510][100],v[510][60];int a[510];int max(int a,int b){return a>b?a:b;}int add(int s,int b);int main(){ int n,k,m,j,i,T,g,maxx,temp; scanf("%d",&T); while(T--) { scanf("%d%d%d",&n,&m,&k); for(i=1;i<=n;i++) 阅读全文

posted @ 2011-07-21 12:04 sleeper_qp 阅读(213) 评论(0) 推荐(0) 编辑

导航