上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页
摘要: 素数唯一分解定理#include <iostream> #include <math.h> using namespace std; long long f[15][110]; int t[110]; int main() { long long m,n; for(int i=1;i<=10;i++) { t[i]=0; for(int j=0;j<=i;j++) { for(int k=0;k<=i;k++) { long long x=(long long)(pow(2,double(j))*pow(5,double(k))); if(x<( 阅读全文
posted @ 2012-12-23 11:47 LJ_COME!!!!! 阅读(123) 评论(0) 推荐(0)
摘要: 贪心,刚做此题时,就意识到了是贪心,但贪心思路一直没找对,wa了n次,在纠结中终于想出正确的思路#include <iostream> #include <algorithm> #include <cstdio> using namespace std; struct node { int x,y; }; node f[25]; bool cmp(node a,node b) { return a.y*b.x<b.y*a.x; } int main() { int n; while(cin>>n) { int i; long long am 阅读全文
posted @ 2012-12-23 00:40 LJ_COME!!!!! 阅读(145) 评论(0) 推荐(0)
摘要: 贪心+优先队列#include <iostream> #include <cstdio> #include <vector> #include <queue> using namespace std; const int maxn=50; int h[maxn],n; int main() { int tot=0; while(cin>>n&&n) { tot++; int i; priority_queue<int> q1; priority_queue<int,vector<int>, 阅读全文
posted @ 2012-12-22 09:47 LJ_COME!!!!! 阅读(136) 评论(0) 推荐(0)
摘要: //枚举+贪心+优先队列 //最有的方案肯定是从起点走到某个点终止,然后在这条路上通过贪心选择最优的选择(每个点应停留的时间)。最后通过比较得出最优的方案 #include <iostream> #include <queue> #include <cstdio> #include <cstring> using namespace std; const int maxn=26; int t_spent[maxn],eve[maxn][maxn],cost[maxn],d[maxn]; int n,h; struct node { int num 阅读全文
posted @ 2012-12-21 17:13 LJ_COME!!!!! 阅读(139) 评论(0) 推荐(0)
摘要: #include <iostream> #include <string> #include <cstdio> #include <algorithm> using namespace std; const int maxn=55; string f[maxn]; int n; bool cmp(string a,string b) { return a+b>b+a; } int main() { while(cin>>n&&n) { for(int i=0;i<n;i++) cin>>f[i] 阅读全文
posted @ 2012-12-21 17:11 LJ_COME!!!!! 阅读(144) 评论(0) 推荐(0)
摘要: 又是网络流的建模.二分枚举答案。做这道题时,感觉做过类似的,想都没想就用之前的那个思路做了,结果错的。之前的思路就是,先求出任意两点间的最短路径,然后通过当前枚举的限制,把两点间路径在这个限制内的两点直接i连一条双向边。建s,t,s点到所有点连一条有向边,所有点到t连一条有向边。但这思路是错的,因为虽然在建的图中,任何从s到t的一个流的路径中的相临两点是在限制中,但这些满足限制的边可能经过组合就会大于限制,那么通过这条路径的流肯定是不满足限制的,所以给出的限制在这种情况下就完全违背了限制的初衷,也就会得到错误的结果。任何一个牛要走的话,肯定是从一个点i运动到j(j可以为i),中间怎么走的不需要 阅读全文
posted @ 2012-12-16 15:51 LJ_COME!!!!! 阅读(157) 评论(0) 推荐(0)
摘要: 先通过dp求出LIS假设为m,也就是经典的LIS问题。就求出了以点i为终点的LIS,即d[i];然后题目要求输出所有点都不重合的LIS的方案。可以通过最大流来求解。可以想到一个从s到t的流对应于一种方案。LIS的终点很显然只能是d值为m的点,所以在模型中只把d值为m的点向终点t连一条有向边。任何一个LIS的起点一定是d值为1的点所以s向d值为1的点连一条有向边。然后对于每一个点i,把j<i且的d[j]+1=d[i],从j想i连一条边,这样每一条从s出发的路都是一个上升子序列,如果到达终点是t则是一个最长上升子序列,然后因为点都只能用一次,所以设定点的容量为1,这样得到的模型一个流就是最终 阅读全文
posted @ 2012-12-15 18:45 LJ_COME!!!!! 阅读(140) 评论(0) 推荐(0)
摘要: 最大权独立子集检查了四个小时,最后发现是输出的问题,哎,抓狂#include <iostream> #include <cstdio> #include <queue> #include <cstring> using namespace std; const int maxn=200*2; const int maxe=maxn*maxn*4; const int inf=1<<28; int val[maxn]; int m,n,s,t,tot,clo; struct Edge { int from,to,next; }; Edg 阅读全文
posted @ 2012-12-14 19:12 LJ_COME!!!!! 阅读(131) 评论(0) 推荐(0)
摘要: 最大权闭合图,建议和我一样不知道这个模型的acmer搜一下——国家集训队2007论文集7.胡伯涛《最小割模型》。下面我就谈一下我对最大权闭合图的理解。知道了最大权闭合图的模型后,此题可看做是求最大权闭合图。首先,原图是一些有着权值的点,那么目的就是在这些点中选择一些点,但选一个点i,必须选择它的前提条件的所有点,那么怎么选才能符合这一限制条件呢。那么在点i和i的前提条件的所有点之间连接一条有向边表示有联系。那么现阶段的问题就转换成了在刚建好的图中选择闭合子图,这一闭合图中的点就是要选择的点。然后因为要求权值最大,最终转换成了最大权闭合子图。然后就是最大权闭合子图怎么求。注意到最后所有的点就只有 阅读全文
posted @ 2012-12-12 19:42 LJ_COME!!!!! 阅读(207) 评论(0) 推荐(0)
摘要: 很久没有一次a的感觉啦。关键是建模,建一个有b+2个点的网络流,s为0,t为b+1,1--b为各个棚。二分枚举答案。s到各棚的容量为当前可行区间内,可选择此棚的牛的个数,各棚到t的容量为割棚可容纳牛的个数。数据量不大,直接用的EK.#include <iostream> #include <cstdio> #include <queue> using namespace std; const int maxn=1001; const int maxe=25; const int inf=200000000; int n,b,tot,s,t; int flow 阅读全文
posted @ 2012-12-10 14:15 LJ_COME!!!!! 阅读(170) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页