上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 57 下一页

2011年7月22日

poj 1860 Currency Exchange

摘要: #include <iostream> //Bellman-Ford算法的变形,参照 poj 2240 Arbitrageusing namespace std;const int maxnum = 102;int n,m,s,a,b;double v,r1,c1,r2,c2;typedef struct Edge{ int u, v; double ex,com; }Edge;Edge edge[1000]; double dist[maxnum]; int nodenum, edgenum; void input(){ cin>>n>>m>> 阅读全文

posted @ 2011-07-22 20:28 sysu_mjc 阅读(169) 评论(0) 推荐(0) 编辑

poj 1845 Sumdiv

摘要: #include<iostream> //求 A^B 的所有约数之和using namespace std;const __int64 mod=9901;__int64 fac[1000],num[1000],rear;__int64 root(__int64 a,__int64 b) //二分法求解 a^b { if(b==0) return 1; else if(b==1) return a%mod; __int64 c=root(a,b/2),d=c*c%mod; if(b%2==0) return d; else return d*a%mod;}void factor(__ 阅读全文

posted @ 2011-07-22 20:27 sysu_mjc 阅读(191) 评论(0) 推荐(0) 编辑

poj 1753 Flip Game

摘要: //题意:在一个4*4的棋盘上翻转棋子,棋子只有黑白两色,翻转了一个棋子以后,他的上下左右四个方向的棋子都得跟着变色,//最后使得棋盘上所有的棋子都是白色,或者都是黑色。统计最少需要翻转棋子的个数。#include<iostream> //bfs+位运算 参照 poj8 1166 The Clocks#include <stdio.h>using namespace std;const int mod=0x55555555; //mod=(0101 0101 0101 0101 0101 0101 0101 0101)十六进制,实际上是16,4*4个 01 int f. 阅读全文

posted @ 2011-07-22 20:26 sysu_mjc 阅读(163) 评论(0) 推荐(0) 编辑

poj 1664 放苹果

摘要: #include<iostream> //构造非下降序列(这样才能不重复),统计其个数using namespace std;int t,m,n,ans[15],sum,s;void dfs(int r){ if(r==n) { if(m-sum>=ans[r-1]) s++; return ; } for(int i=ans[r-1];sum+i<=m;++i) { ans[r]=i; sum+=ans[r]; dfs(r+1); sum-=ans[r]; }}int main(){ int t; cin>>t; while(cin>>m> 阅读全文

posted @ 2011-07-22 20:25 sysu_mjc 阅读(91) 评论(0) 推荐(0) 编辑

poj 1502 MPI Maelstrom

摘要: #include <iostream> //最短路径的最长边using namespace std; const int MAXN=120;const int INF=1<<30; int n,edge[MAXN][MAXN],distD[MAXN],vis[MAXN];int ans;void Dijstra(int st) //从源点st到其余各顶点的最短路径长度{ memset(vis,0,sizeof(vis)); for(int i=0;i<n;++i) //结点... 阅读全文

posted @ 2011-07-22 20:24 sysu_mjc 阅读(171) 评论(0) 推荐(0) 编辑

poj 1656 Counting Black

摘要: #include<iostream>#include<string>using namespace std;int table[101][101];int main(){ string str; int n,x,y,l; cin>>n; while(n--) { cin>>str>>x>>y>>l; if(str=="BLACK") for(int i=x;i<x+l;++i) for(int j=y;j<y+l;++j) table[i][j]=1; else if(str== 阅读全文

posted @ 2011-07-22 20:24 sysu_mjc 阅读(103) 评论(0) 推荐(0) 编辑

poj 1459 Power Network

摘要: #include<iostream> //多源多汇网络流,参考poj8 1273 Drainage Ditches#include<queue>using namespace std;#define inf 0x7fffffffint flow[102][102],cap[102][102],a[102],p[102],s,t,f;int n,np,nc,m,u,v,z;void ek(){ queue<int> col; memset(flow,0,sizeof(flow)); f=0; while(1) { memset(a,0,sizeof(a)); 阅读全文

posted @ 2011-07-22 20:23 sysu_mjc 阅读(114) 评论(0) 推荐(0) 编辑

poj 1273 Drainage Ditches

摘要: #include<iostream> //网络流#include<queue>using namespace std;#define inf 0x7fffffffint flow[202][202],cap[202][202],a[202],p[202],s,t,f;int main(){ int n,m; while(cin>>n>>m) { memset(cap,0,sizeof(cap)); int si,ei,ci; while(n--) { cin>>si>>ei>>ci; cap[si][ei]+= 阅读全文

posted @ 2011-07-22 20:22 sysu_mjc 阅读(119) 评论(0) 推荐(0) 编辑

poj 3984 迷宫问题

摘要: #include<iostream>#include<deque>using namespace std;struct node{ int path[25][2]; int t;}ans[30];int arr[5][5],vis[5][5],pos[4][2]={{-1,0},{0,1},{1,0},{0,-1}};int main(){ for(int i=0;i<5;++i) for(int j=0;j<5;++j) cin>>arr[i][j]; deque<node> col; int m=1; ans[0].path[0] 阅读全文

posted @ 2011-07-22 20:20 sysu_mjc 阅读(118) 评论(0) 推荐(0) 编辑

poj 3620 Avoid The Lakes

摘要: #include<iostream> //dfsusing namespace std;bool visited[105][105],rec[105][105];int n,m,k,s,ans[8]={-1,0,1,0,0,-1,0,1};void dfs(int r,int c){ s++;visited[r][c]=1; for(int i=0;i<4;++i) { int a=ans[2*i],b=ans[2*i+1]; if(r+a>=1&&r+a<=n&&c+b>=1&&c+b<=m & 阅读全文

posted @ 2011-07-22 20:19 sysu_mjc 阅读(100) 评论(0) 推荐(0) 编辑

上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 57 下一页

导航