上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 57 下一页

2011年7月22日

poj 2078 Matrix

摘要: #include<iostream> //搜索题using namespace std;int n,table[10][10],m,s,mx;void backtrack(int r){ if(r==n) { m=0; for(int j=0;j<n;++j) { s=0; for(int i=0;i<n;++i) { s+=table[i][j]; if(s>=mx) //剪枝 return ; } m=max(s,m); } mx=min(mx,m); } else { int t=n; while(t--) { int p=table[r][n-1]; fo 阅读全文

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

poj 2251 Dungeon Master

摘要: #include<iostream> //bfsusing namespace std;int vis[30][30][30],pos[4][2]={{-1,0},{0,1},{1,0},{0,-1}};char arr[30][30][30];int l,r,c;struct node{ int d,x,y,p;}ans[30000];int main(){ int sd,sx,sy; while(cin>>l>>r>>c&&l) { memset(vis,0,sizeof(vis)); for(int i=0;i<l;+ 阅读全文

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

poj 2063 Investment

摘要: // 题意: 开始时有一定数量的钱,有d种股票可以买,给出每种股票的价格和年收益,股票价格是1000的倍数// 如何使得投资的收益最大,即到最后手上的钱最多.#include<iostream> //完全背包 using namespace std;int dp[5000000];int main(){ int n,t,d,v,bond[50],interest[50]; cin>>n; while(n--) { cin>>v>>t>>d; for(int i=1;i<=d;++i) ... 阅读全文

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

poj 1887 Testing the CATCHER

摘要: #include<iostream> //最长不上升子序列using namespace std;int main(){ int cases=1,seq[10000],p; while(scanf("%d",&p),p!=-1) { int rear=0; seq[++rear]=p; while(scanf("%d",&p),p!=-1) { if(p<=seq[rear]) //当p==seq[rear],可以压入最长不上升子序列中 seq[++... 阅读全文

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

poj 1922 Ride to School

摘要: #include <iostream>using namespace std;int main(){ int n,v,t; while(cin>>n&&n) { int s=9999999; for(int i=0;i<n;++i) { cin>>v>>t; if(t>=0) { double a=4.5*3600/v; if(a-(int)a>0) a++; if(a+t<s) s=a+t; } } cout<<s<<endl; } return 0;}//找一个达到时间最少的,输 阅读全文

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

poj 1862 Stripies

摘要: #include<iostream>#include<vector>#include <algorithm>#include <cmath>using namespace std;int main(){ vector<double> col; int n;double a,e1,e2; cin>>n; for(int i=0;i<n;++i) { cin>>a; col.push_back(a); } sort(col.begin(),col.end()); for(int i=n-1;i>0;-- 阅读全文

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

poj 1844 Sum

摘要: #include<iostream>using namespace std;int main(){ int s,sum=0; cin>>s; for(int i=1;;++i) { sum+=i; if(sum>=s&&(sum-s)%2==0) { cout<<i<<endl; break; } } return 0;} bfs tle#include <iostream> //bfs tle#include <deque>using namespace std;int s;struct node{ 阅读全文

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

poj 1836 Alignment

摘要: // 题意:战士们站成一排,要求每个人都能看到在他左边或右边的所有人,// 只要有另外一人不比他矮,他就无法看到尽头了,问要至少出队多少人,即是求满足条件的最长子序列// 比如 1 2 3 4 4 3 2 1 就满足条件,但 1 2 3 3 3 2 1 不满足,因为中间有一个3不能看到左边或右边的尽头。// 分成两半,左半部分是最长严格上升子序列,范围[1-i],长度为Len1;// 而右半部分是最长严格下降子序列,范围[i+1-n],长度为Len2// 需要用 LIS算法 从前往后跑一遍,然后从后往前再跑一遍// 思路:枚举 i (1<=i<=n),利用LIS算法计算出Len1和 阅读全文

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

poj 1742 Coins

摘要: #include<iostream>using namespace std;int v[105],c[105],b[100005][2]; int main(){ int n,m,i,j,count,num; while(scanf("%d%d",&n,&m),n&&m) { memset(b,0,sizeof(b)); for(i=1;i<=n;i++) scanf("%d",&v[i]); for(i=1;i<=n;i++) scanf("%d",&c[i]) 阅读全文

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

poj 1631 Bridging signals

摘要: //最长严格上升子序列#include<iostream> //时间复杂度为O(nlogn)#include<algorithm>#include<vector>using namespace std;int main(){ int n,p,a; cin>>n; while(n--) { cin>>p>>a; vector<int> col; col.push_back(a); for(int i=1;i<p;++i) { cin>>a; if(a>col[col.size()-1]) 阅读全文

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

上一页 1 ··· 18 19 20 21 22 23 24 25 26 ··· 57 下一页

导航