05 2012 档案

poj 1679 The Unique MST ( 次小生成树 )
摘要:(n^3) -- kruskal 枚举边#include<stdio.h>#include<iostream>#include<algorithm>#include<string.h>#define N 110#define inf 99999999using namespace std;struct node{ int x,y,len;}root[N*N];int n,m,num[N];int top,stack[N];int find(int x){ if(num[x] == x) return x; return num[x] = find 阅读全文

posted @ 2012-05-09 01:33 skyming 阅读(412) 评论(0) 推荐(0)

poj 1734 Sightseeing trip(floyd 拓展 求最小环)
摘要:对于floyd 拓展为什么可以判断 出最小环还是不是太理解苟且 先贴下模版吧感谢:心_随_梦_翔 的分析 http://hi.baidu.com/%D0%C4_%CB%E6_%C3%CE_%CF%E8/blog/item/403b9c58699c7642d0090675.html感谢 我们一直在努力 的代码http://www.cnblogs.com/zhaoguanqin/archive/2012/05/08/2490121.html今天也够是郁闷的inf 开到 9 个 9 而中间 加法 导致溢出了 各种WA ,又找了一万晚上的错误#include<stdio.h>#define 阅读全文

posted @ 2012-05-08 23:37 skyming 阅读(278) 评论(0) 推荐(0)

poj 1201 Intervals( spfa + 差分约束)
摘要:首先感谢 y @ The Angry Teletubbies http://www.cppblog.com/y346491470/articles/152876.html某牛人的总结http://www.cnblogs.com/sysuwhj/archive/2011/01/26/1945773.html#include<stdio.h>#include<stack>#include<string.h>#include<iostream>#include<algorithm>using namespace std;#define N 阅读全文

posted @ 2012-05-08 01:02 skyming 阅读(185) 评论(0) 推荐(0)

codeforces 185B - Mushroom Scientists ( 三分搜索)
摘要:题意: 四个数 s a b c 均为非负 ,求x,y,z 使得x ^a * y^ b* z^c 值最大 其中 s>=x+y+z这个题用拉格朗日函数可以证明 一个结论在 s= x + y +z 时 x=s/(a+b+c) ,y=s/(a+b+c) ,z=s/(a+b+c) 最大x ^a * y^ b* z^c 的值最大证明很关键啊,翻了高数 课本搞弄明白,伤不起啊据某大牛说 可以用 三分搜索 搞定,但是 由于精度卡死 了 不少孩纸 。。。你妹,精度小了,WA ,精度大了,居然卡 边界值 程序和死循环似的幸运的是那时自己还不会,没有被恶心-->__<--处理时 循环加有限的的限定 阅读全文

posted @ 2012-05-07 20:35 skyming 阅读(268) 评论(0) 推荐(0)

hdu 3400 line belt (三分搜索)
摘要:#include<stdio.h>#include<math.h>#define eps 0.00000001struct node{ double x,y;}a,b,c,d;double p,q,r;void init(){ scanf("%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y); scanf("%lf%lf%lf%lf",&c.x,&c.y,&d.x,&d.y); scanf("%lf%lf%lf",&p,& 阅读全文

posted @ 2012-05-06 22:27 skyming 阅读(204) 评论(0) 推荐(0)

buaa 1033 easy problom(三分搜索)
摘要:三分搜索第一题纪念三分搜索对于凹凸函数极值非常有效#include<stdio.h>#include<math.h>#define eps 0.00000001struct node{ double x,y,z;};double dist(node a,node b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));}int main(){ int cs,p=1;scanf("%d",&cs); while(p<=cs) { node p 阅读全文

posted @ 2012-05-06 20:40 skyming 阅读(247) 评论(0) 推荐(0)

poj 3169 Layout (spfa + 查分约束)
摘要:和 poj 3159 相似 :建图 时 多 b-a>=c 这种情况,对于建图时用虚拟节点 不是太懂#include <iostream>#include <cstdio>#include <stack>#include <queue>#include <cstring>#include <algorithm>using namespace std;#define inf 999999999#define V 1001#define E 20001int pnt[E],cost[E],nxt[E],e;int head 阅读全文

posted @ 2012-05-04 10:34 skyming 阅读(214) 评论(0) 推荐(0)

巨水的题目
摘要:// 今天翻了翻以前收藏的东西,居然发现: spfa 用map 写的 ,好吧,stl 我一无所知。题目:hdu 2544 太熟悉了吧#include<stdio.h>#include <map>#include <queue>#define N 101using namespace std;map<int,int> head[N];// head[u][v]=wint spfa(int st,int n) //start{ int i,u,v,w; int vis[N],d[N]; for (i=1;i<=n;i++) {vis[i]=0; 阅读全文

posted @ 2012-05-02 21:24 skyming 阅读(202) 评论(0) 推荐(0)

poj 2253 Frogger (哈哈~~有点意思)
摘要:练练手吧~~~-->__<--关键点:dist[v]=min(dist[v],max(dist[u],cost[i]));spfa#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#include<math.h>#define N 210#define inf 999999999struct node{ int x,y;}point[N*N];int n,m,head[N],e;int pnt[N*N],nxt[N*N];double c 阅读全文

posted @ 2012-05-02 20:52 skyming 阅读(374) 评论(0) 推荐(0)

poj 3259 Wormholes (spfa+判断负权回路+模版)
摘要:面壁: 细节之处,尽显实力;spfa + vector#include <iostream>#include <cstdio>#include <vector>#include <stack>using namespace std;#define inf 99999999#define V 520#define NE 6000int n,m,w;struct node{ int v; int val;}E;vector<node> Node[V+2];int spfa(int k){ int d[V], cnt[V], vis[V]; 阅读全文

posted @ 2012-05-02 17:36 skyming 阅读(424) 评论(0) 推荐(0)