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

2011年7月22日

poj 1606 Jugs

摘要: #include <iostream> //bfs#include <deque>#include <string>using namespace std;struct node{ string path; int posa,posb;}ans[1000000];bool visited[1005][1005];string output[6]={"fill A","fill B","empty A","empty B","pour A B","po 阅读全文

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

poj 1491 Pi

摘要: #include <iostream> //水题#include <cmath>using namespace std;int gcd(int x,int y) { if (x==0||y==0) return max(x,y); int i=0,j=0; while (x&1==0) { ++i; x=x>>1; } while (y&1==0) { ++j; y=y>>1; } i=min(i,j); while(1) { if(x<y) swap(x,y); x-=y; if(x==0) return y<< 阅读全文

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

poj 1504 Adding Reversed Numbers

摘要: #include <iostream>#include <string>using namespace std;int main(){ int n,i,j; string str1,str2; cin>>n; while(n--) { cin>>str1>>str2; if(str1.size()<str2.size()) swap(str1,str2); int t=0; for(i=0;i<str2.size();++i) if(str1[i]+str2[i]-'0'+t>57) str1[i]= 阅读全文

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

poj 1503 Integer Inquiry

摘要: #include <iostream>#include <string>using namespace std;int compare(string str1, string str2){ while(!str1.empty()&&str1[0]=='0') { str1.erase(0,1); } while(!str2.empty()&&str2[0]=='0') { str2.erase(0,1); } if(str1.size() > str2.size()) //长度长的整数大于长度小的整数 阅读全文

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

poj 1455 Crazy tea party

摘要: #include <iostream>using namespace std;int main(){ int t,n,k; cin>>t; while(t--) { cin>>n; k=n/2; cout<<k*(k-1)/2+(n-k-1)*(n-k)/2<<endl; }}//http://blog.sina.com.cn/s/blog_6f71bea30100oxyz.html 阅读全文

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

poj 1154 LETTERS

摘要: #include<iostream> //dfsusing namespace std;bool visited[26];char board[100][100];int r,s,n;bool vis(int x,int y){ if(x<1||x>r||y<1||y>s) return true; return visited[board[x][y]-'A'];}void dfs(int x,int y,int num){ if(vis(x-1,y)&&vis(x+1,y)&&vis(x,y-1)&& 阅读全文

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

poj 1111 Image Perimeters

摘要: #include<iostream> //dfsusing namespace std;int r,c,mr,mc,num,ans[25][25],vis[25][25];int pos[4][2]={{-1,0},{0,1},{1,0},{0,-1}},slo[4][2]={{-1,1},{1,1},{1,-1},{-1,-1}};void dfs(int x,int y){ vis[x][y]=1; int px,py; for(int i=0;i<4;++i) { px=x+pos[i][0];py=y+pos[i][1]; if(ans[px][py]==0) num 阅读全文

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

poj 3624 Charm Bracelet

摘要: #include <iostream> //0-1背包using namespace std;int dp[20000],weigh[5000],val[5000];int main(){ int n,m,i,j; cin>>n>>m; for(i=0;i<n;++i) cin>>weigh[i]>>val[i]; for(i=n-1;i>=0;--i) for(j=m;j>=weigh[i];--j) dp[j]=max(dp[j],dp[j-weigh[i]]+val[i]); cout<<dp[m] 阅读全文

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

poj 3628 Bookshelf 2

摘要: #include <iostream>#include <algorithm>#include <functional>using namespace std;int arr[25],s,n,b,shelf[20000005];void dfs(int i){ s+=arr[i]; shelf[s]=1; if(s==b) return ; else if(s>b) s-=arr[i]; else { for(int j=i+1;j<n;++j) { dfs(j); if(s==b) return ; } s-=arr[i]; }}int mai 阅读全文

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

poj 3414 Pots

摘要: #include <iostream> //BFS#include <string>#include<deque>using namespace std;struct Node{ int f1,f2; string path; Node() { f1=f2=0; path=""; }}node[10000];int t,visited[105][105];int main(){ int a,b,c,e1,e2; string str; cin>>a>>b>>c; deque<Node> co 阅读全文

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

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

导航