题解:
有N个股票经济人可以互相传递消息,他们之间存在一些单向的通信路径。现在有一个消息要由某个人开始传递给其他所有人,问应该由哪一个人来传递,才能在最短时间内让所有人都接收到消息。
显然,用Floyd算法,然后选出每个点到其他点的最长距离当中的最短距离。
/** \brief poj 1125 Floyd
*
* \param date 2014/7...
分类:
其他好文 时间:
2014-07-31 17:07:36
阅读次数:
218
欧几里得- -要分N种情况- -#include#includeusing namespace std;int gcd(int x,int y){if (y==0) return x;return gcd(y,x%y);}struct node{ int x,y; friend ...
分类:
其他好文 时间:
2014-07-31 16:18:27
阅读次数:
156
题意:
构造一幅图 使题中给出的程序按该图执行 最终变量doge大于输入的C跳出
思路:
出题人思维简直神了! 实在是膜拜! 借题解的图:
按照图中所画 可以继续向右延伸
为何这样可以?? 为何边权要这么取??
先回答第二个问题:
取负数是为了可以不断的去更新 例如如果走了上面的-4那条边 那么它右边的所有点就又可以再更新一次 这样使更新达到了指数级...
分类:
其他好文 时间:
2014-07-31 00:08:45
阅读次数:
300
Bellman-ford算法的反向应用--正循环检查
/** \brief poj 1860 Bellman-Ford
*
* \param date 2014/7/24
* \param state AC
* \return memory 708K time 141ms
*
*/
#include
#include
#include
using namespace std...
分类:
其他好文 时间:
2014-07-31 00:01:23
阅读次数:
213
我们知道,增广路EK算法的时间负责度是O(n*m^2),找最短增广路的时间复杂度是O(m*n),所以时间复杂度主要是在找增广路上。
这里介绍另一种Dinci算法,用BFS构造层次图,然后用DFS增广。
模板
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#d...
分类:
其他好文 时间:
2014-07-30 14:49:03
阅读次数:
364
Description
In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the seq...
分类:
其他好文 时间:
2014-07-30 12:22:33
阅读次数:
290
对于每个位置的馅饼数目只上一秒它本身和左右位置的最大馅饼数有关。。
也可将他看做数塔。。
从后往前找最大值。。
#include
#include
#include
#include
#include
using namespace std;
int s[11][100001];
int yy[11];
int e,f;
int maxn(int y,int u,int k...
分类:
其他好文 时间:
2014-07-30 12:15:53
阅读次数:
189
1 概述 算法(Algorithm)是指解题方案的准确而完整的描述,是一系列解决问题的清晰指令,算法代表着用系统的方法描述解决问题的策略机制。一个算法的优劣可以用空间复杂度和时间复杂度来衡量。2 特征 一个算法应该有一下五个重要特征:有穷性、确切性、输入项、输出项、可行性。3 要素 一,数据对...
分类:
其他好文 时间:
2014-07-30 11:48:53
阅读次数:
215
不知为毛,过不了我的代码:#includeint main(){int n,a[30],b[30],temp,i,j,s1,s2;double c[30];while(scanf("%d",&n)!=EOF){s1=0;s2=0;for(i=0;i #include usingnamespacest...
分类:
其他好文 时间:
2014-07-30 11:33:43
阅读次数:
215