雕刻时光

just do it……nothing impossible
随笔 - 547, 文章 - 0, 评论 - 82, 阅读 - 86万
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

03 2012 档案

摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1788注意门与门之间可能有多条路!!输入可以连通就相应的边就 + INF判断 map[i][j]>=inf 反面就又map[j][i]=map[i][j]/inf 容量的路算最大流,if flow>=inf 则 入侵 else flowView Code #include<stdio.h>#include<string.h>int map[39][39];const int inf=100000000;const int MAXN=39;i 阅读全文

posted @ 2012-03-29 22:24 huhuuu 阅读(382) 评论(0) 推荐(0) 编辑

摘要:类似于二分匹配的构图,相乘可以用log 后相加解决View Code #include<iostream>#include<cmath>#include<stdio.h>#include<string.h>using namespace std;const double inf=500.0;const int MAX=105;struct node{ int v,next; double c;}g[100000];int num[MAX],dis[MAX],cur[MAX],adj[MAX],pre[MAX];int s,t,e,vn,r,c,l 阅读全文

posted @ 2012-03-28 21:45 huhuuu 阅读(272) 评论(0) 推荐(0) 编辑

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3826判断一个数的约数是否开根号为一个整数,存在输出no,否则yes先1-1000,000之间的素数去试除该数,同一个素数有两次以上将其整除的话,是no,结束没结束,将余数开根号,看是否是一个整数,是no,否则yesView Code #include<stdio.h>#include<math.h>#include<string.h>int ha[1000005],shu[1000005];int main(){ int t,i,j,k; memset(shu,1,siz 阅读全文

posted @ 2012-03-26 21:20 huhuuu 阅读(474) 评论(0) 推荐(0) 编辑

摘要:http://poj.org/problem?id=3469网络流的模型:每个模块一个节点,原点与所有模块节点连接(称为上边),边权为第一个核对应该模块的开销。所有模块节点连接到汇点(称为下边),权为第二个核对应该模块的开销。然后需要数据交换的两个模块结点之间连接双向边(两个单向边,称为中边),权为对应的那个额外开销。View Code #include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int MAXN = 20000;const int INF = 1 阅读全文

posted @ 2012-03-24 22:03 huhuuu 阅读(278) 评论(0) 推荐(0) 编辑

摘要:http://poj.org/problem?id=1637题意:混合图欧拉回路一开始想到是否可以用欧拉回路做,可是一想a->b ,a<->b可以同时并且多次存在时,不可行构图:有向边忽略,无向边任意定向。统计每个点的出入度(有向边当无向边)。对于任意一个点,若有出入度之差为奇数则不可能存在欧拉路。记|出度-入度|=K。对于出度大于入度的点从S向I连容量为K/2的边,对于出度小于入度的点从I向T连容量为K/2的边。原来的无向边,任意定向,从X向Y连容量1的边。求最大流,判每条从S流出的边的流量和all是否等于最大流,是则存在欧拉路否则不存在。注意点:会有重边出现!而且重边也要 阅读全文

posted @ 2012-03-22 21:51 huhuuu 阅读(676) 评论(0) 推荐(0) 编辑

摘要:先 folyd 求出任意两点可以到达的距离,由于我们不知道最短距离为多少,所以用二分查找来逼近答案接着构建容量网络:增加 源点 (n+1),设置源点到牛的容量为1 (一开始以为是INF,显然是错的)增加 汇点 (0),设置汇点到机器的容量为 M在通过二分出来的那个答案,统计牛到机器的容量最后网络流最大流,继续二分,直到最佳答案View Code #include<stdio.h>#include<string.h>const int inf=100000000;const int MAXN=309;int map[MAXN][MAXN];int dis[MAXN][MA 阅读全文

posted @ 2012-03-21 22:36 huhuuu 阅读(337) 评论(0) 推荐(0) 编辑

摘要:http://poj.org/problem?id=1273人生第一题网络流O(∩_∩)O哈哈~注意数据有重边,要把值加上去View Code #include<stdio.h>const int inf=1000000000;const int MAXN=209;int map[MAXN][MAXN];int flow[MAXN][MAXN];int max_flow(int n,int mat[][MAXN],int source,int sink){ int v[MAXN],c[MAXN],p[MAXN],ret=0,i,j; for(;;){ for(i=0;... 阅读全文

posted @ 2012-03-21 19:47 huhuuu 阅读(376) 评论(0) 推荐(0) 编辑

摘要:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1184优先小节点搜欧拉道路,如果有奇数入度节点要从这个节点出发。注意从小到大在算法遍历里是1->n!!!!path输出来时是n->0!!!! 要是以为算法遍历里是n->1,path输出来时是0->n那就错了数据42 31 23 11 2会输出:2 1 2 3 1 错!!!!View Code #include<stdio.h>#include<string.h>#include<iostream>#include<algorith 阅读全文

posted @ 2012-03-18 21:23 huhuuu 阅读(431) 评论(0) 推荐(0) 编辑

摘要:有一些由“_"和"#"组成的图形,图形中由"#"拼成了"B"、"M"、"W"三种字母,。用程序识别这些字母,统计三个字母的个数。___###############___________________________________###################_______________________________#####################_____________________________#####_____________#####_____ 阅读全文

posted @ 2012-03-18 19:43 huhuuu 阅读(384) 评论(0) 推荐(0) 编辑

摘要:难点不在贪心,在于对字符串的处理,字符串处理为数字sscanf就可以了View Code #include<iostream>#include<algorithm>#include<stdio.h>#include<string.h>#include<math.h>using namespace std;struct data{ double x,y; int time;}s[100009];double dis[100009];double fdis(double x0,double y0,double x1,double y1){ 阅读全文

posted @ 2012-03-15 21:42 huhuuu 阅读(180) 评论(0) 推荐(0) 编辑

摘要:3abxcybzca转化---->1 1 12 2 13 2 1i :1->nj:1->ndp[i][j]=min(dp[i][j],dp[i-1][j+1]);View Code #include<stdio.h>char map[1009][1009];int a[1009][1009];int min(int a,int b){ if(a>b)return b; else return a;} int main(){ int n; while(scanf("%d",&n)!=EOF) { if(n==0)return 0; 阅读全文

posted @ 2012-03-10 22:19 huhuuu 阅读(287) 评论(0) 推荐(0) 编辑

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2855实际就是求fibonacci的2*n个用二分矩阵算View Code #include<stdio.h>#include<string.h>int mod;struct data{ int map[2][2];};data matrix(data a,data b)//矩阵乘法{ int n=2; int i,j,k; data re; for(i=0;i<n;i++) { for(j=0;j<n;j++) { int... 阅读全文

posted @ 2012-03-10 19:33 huhuuu 阅读(234) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示