上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 57 下一页

2011年7月22日

poj 1634 Who's the boss?

摘要: #include<iostream> //排序#include<stdio.h>#include<algorithm>#include<vector>using namespace std;int n,m,q,y,k;struct node{ int id,sala,height; int boss,child; //sub存储第一层下属的位置,child记录所有下属subordinate的数目 vector<int> sub; bool operator<(const node& o)const //降序 { retu 阅读全文

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

poj 1654 Area

摘要: #include<iostream> //多边形面积#include<string>using namespace std;struct point{ int x,y;}p[1000010];int move[10][2]={{},{-1,-1},{0,-1},{1,-1},{-1,0},{},{1,0},{-1,1},{0,1},{1,1}};int main(){ int cases; string str; cin>>cases; while(cases--) { cin>>str; int n=str.size()-1; if(n< 阅读全文

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

poj 1620 Phone Home

摘要: #include<iostream> //求图的色数,即使各相邻顶点的颜色不相同所需的最小色数.数据量小,直接枚举+DFS#include<stdio.h>#include<cmath>#include<cstring>using namespace std;struct node{ double x,y;}point[20];int n,cnt[20][20],color[20],num,suc;void dfs(int i){ for(int c=1;c<=num;++c) { int flag=1; for(int j=0;j< 阅读全文

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

poj 1580 String Matching

摘要: #include<iostream>#include<string>using namespace std;int gcd(int n,int m) //辗转相除法{ int r; if(n<m)swap(n,m); while(m!=0) { r=n%m; n=m; m=r; //永远符合n>=m } return n;}int main(){ char str[10000],ctr[10000]; while(cin>>str&&strcmp(str,"-1")!=0) { cin>>ctr; 阅读全文

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

poj 1511 Invitation Cards

摘要: #include<iostream> //Dijkstra+优先队列 1735MS!#include<queue>#define maxn 1000002using namespace std;struct Edge { int v; int weight; int next;}Vertex[maxn];int head[maxn],curr; const __int64 inf=(__int64)1<<63-1; int cases,p,e,i,j,edge[maxn][3];void graph(int tag){ int u,v,w; curr=0; 阅读全文

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

poj 1493 Machined Surfaces

摘要: #include<iostream> #include<string>#include<algorithm>using namespace std;int main(){ string str[20]; int blank[20],n,low,sum; while(cin>>n&&n) { scanf("\n"); for(int i=0;i<n;++i) { getline(cin,str[i]); blank[i]=0; for(int j=0;j<str[i].size();++j) if(s 阅读全文

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

poj 1426 Find The Multiple

摘要: // 题意: 求能整除n的十进制数,由0或1组成#include<iostream> // DFSusing namespace std;int n,ok;int num[100]={1}; //一定是以 1 开头int mod(int cur) //判断num[0]-num[cur]所表示的值能否被n整除{ int s=0; for(int i=0;i<=cur;++i) { s=(s*10+num[i])%n; } return s;}void dfs(int cur){ if(cur>=100) /... 阅读全文

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

poj 1325 Machine Schedule

摘要: /* 题意: 有两台机器A和B,分别有n种和m种不同的模式, 有k个工作,每个工作都可以在那两个机器的某种特定的模式下处理, 如job[0]既可以在A机器的3号模式下处理,也可以在B机器的4号模式下处理, 初始时两台机器都在0号模式下工作,机器的工作模式改变只能通过重启来改变, 通过改变工作的顺序和分配每个工作给合适的机器可以减少重启机器的次数,求重启机器的最少次数 思路: 令X,Y分别是机器A和B的工作模式集合,工作在A和B机器上的工作模式分别为X[a]和Y[b],让X[a]与Y[b]相连, 这样我们就可以X和Y作为两个顶点集合来建立二分图,重启机器的次数就是覆盖所有的边的顶点数。 所以问. 阅读全文

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

poj 1365 Prime Land

摘要: #include<iostream>#include<string>using namespace std;bool isprime(int n){ for(int i=2;i*i<=n;++i) if(n%i==0) return false; return true;}int pe[1000];int main(){ string str; while(getline(cin,str)&&str!="0") { int s=0,id=0; for(int i=0;i<str.size();++i) { if(str[i 阅读全文

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

poj 1281 MANAGER

摘要: #include<iostream> //模拟题#include<set>using namespace std;int out[100000],query[100000];bool first;int main(){ int max_cost,len; while(cin>>max_cost) { cin>>len; for(int i=0;i<len;++i) cin>>query[i]; char ch; int p=1,x,r=1; set<int> col; while(cin>>ch,ch!= 阅读全文

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

上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 57 下一页

导航