摘要: 首先感谢 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 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 题意: 四个数 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 阅读(250) 评论(0) 推荐(0) 编辑
摘要: #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 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 三分搜索第一题纪念三分搜索对于凹凸函数极值非常有效#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 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 和 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 阅读(207) 评论(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 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 练练手吧~~~-->__<--关键点: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 阅读(362) 评论(0) 推荐(0) 编辑
摘要: 面壁: 细节之处,尽显实力;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 阅读(411) 评论(0) 推荐(0) 编辑
摘要: spfa 的处理 栈比队列快了很多,前几天vongang 说,当时还不信这题是见证了,队列 直接 RE ,栈 500Ms#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define inf 999999999#define V 30005#define E 150005int n,m;int nxt[E],pnt[E],cost[E];int vis[V], d[V], head[V];void init(){ 阅读全文
posted @ 2012-04-30 10:06 skyming 阅读(389) 评论(0) 推荐(0) 编辑
摘要: 本题面壁: 1:数据的范围 (在第一次写代码马虎后,很不容易找出) 2:思路清晰后在写代码。。。、#include<iostream>#include<cstdio>#include<string>#include<string.h>#include<map>#define N 35using namespace std;struct node{ int st,ed; double key;}num[N*N];int n,m;int bellman(int s){ double dist[N]; for(int i=0;i<=n 阅读全文
posted @ 2012-04-25 17:26 skyming 阅读(166) 评论(0) 推荐(0) 编辑