上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 57 下一页

2011年7月22日

poj 1331 Multiply

摘要: // 题意: 在b(2<=b<=16)进制下,p*q是否等于r,找出满足条件的最小b. 可以把三个数先转化成十进制,再来比较#include <iostream>#include <string>using namespace std;int base(int n) //返回能表示n的最小进制b{ char s[10]; sprintf(s,"%d",n); int b=0; for(int i=0;i<strlen(s);++i) b = s[i]-'0' > b ? s[i]-'0':b; 阅读全文

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

poj 1276 Cash Machine

摘要: #include<iostream> //多重背包,ac using namespace std;int cash,n,ni[15],di[15],dp[100005];int main(){ while(cin>>cash>>n) { for(int i=1;i<=n;++i) cin>>ni[i]>>di[i]; if(cash==0||n==0) { cout<<"0\n";continue; } memset(dp,0,sizeof(dp)); for(int i=1;i<=n;++ 阅读全文

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

poj 1251 Jungle Roads

摘要: #include <iostream> // 最小生成树kruskal算法#include <algorithm>using namespace std;const int maxn=30,maxm=80;int n,m; //n,m分别是结点数和边数int p[maxn]; //记录并查集中该结点的父亲int u[maxm],v[maxm],w[maxm]; //保存边的端点序号和权值int r[maxm]; //用于间接排序--排序的关键字是对象的“代号”,而不是对象本身int cmp(const int i,const int j){ ... 阅读全文

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

poj 1260 Pearls

摘要: #include <iostream> //DP#include <numeric>using namespace std;#define ed 105int ai[ed],pi[ed],dp[ed]; int main(){ int t,c; cin>>t; while(t--) { cin>>c; for(int i=1;i<=c;++i) cin>>ai[i]>>pi[i]; fill(dp,dp+ed,100000000); //初始化为极大值 dp[0]=0; for(int i=1;i<=c;++i 阅读全文

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

poj 1228 Grandpa's Estate

摘要: //凸包问题,给出n个顶点,问是否唯一确定凸多边形,//只要构建的凸包每条边上至少包含3个顶点即是唯一//在构建好凸包后,要特别处理最后一条边,生成凸包时最后一条边包含第一个和最后一个顶点,但其他共线的顶点不会被包含进去,所以需要额外判断#include <iostream> #include <algorithm>#include <cmath>using namespace std;struct point { int x,y;}st;point castle[1005];double dis(point a,point b){ return sq... 阅读全文

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

poj 1157 LITTLE SHOP OF FLOWERS

摘要: /* 题意: 有n束花和m个花瓶,一束花 i 插在一个花瓶 j 中都有一个对应的美观值 A[i][j], 现在要将这n束花全部插入花瓶中并使得所有的花的美观值最大,求该最大值. 题目规定若i<j,则第i束花必须出现在第j束花之前, 设 ans[i,j] 为前 i 束花插在前 j 个花瓶中的最大美学值, 则有状态转移方程:ans[i,j]=max(ans[i-1,k-1]+A[i,k]),其中i<=k<=j, A[i,k] 为第 i 束花插在第 k 个花瓶中的美学值,规定ans[0,j]=0,0<=j<=m*/#include <iostream> // 阅读全文

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

poj 1089 Intervals

摘要: #include<iostream> //水题#include<algorithm>using namespace std;int n;struct Node{ int beg,end; bool operator<(const Node& other) { if(beg==other.beg) return end>other.end; return beg<other.beg; }}node[50005];int main(){ cin>>n; for(int i=0;i<n;++i) cin>>node[i] 阅读全文

posted @ 2011-07-22 16:59 sysu_mjc 阅读(143) 评论(0) 推荐(0) 编辑

poj 1077 Eight

摘要: // 题意:八数码问题,需要打印路径#include <iostream> // BFS 康托展开判重#include <string.h>#include <stack>using namespace std;typedef int State[9];const int MAXSTATE=1000000;State st[MAXSTATE],goal;int fa[MAXSTATE],mv[MAXSTATE];int fac[]={1,1,2,6,24,120,720,5040,40320,362880};//9!表 int cantor(State no 阅读全文

posted @ 2011-07-22 16:58 sysu_mjc 阅读(117) 评论(0) 推荐(0) 编辑

poj 1083 Moving Tables

摘要: #include <iostream>#include <algorithm>using namespace std;struct node{ int x,y; bool operator<(const node& o) { return x<o.x; }}ans[300];int main(){ int t,n,i,s,tag[300]; cin>>t; while(t--) { cin>>n; int a,b; for(i=0;i<n;++i) { cin>>a>>b; if(a>b) 阅读全文

posted @ 2011-07-22 16:58 sysu_mjc 阅读(132) 评论(0) 推荐(0) 编辑

poj 1035 Spell checker

摘要: #include <iostream> //水题#include<string>#include <vector>#include <algorithm>using namespace std;int main(){ vector<string> dic; string str; while(cin>>str&&str!="#") { dic.push_back(str); } while(cin>>str&&str!="#") { if( 阅读全文

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

上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 57 下一页

导航