上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 36 下一页

2011年7月7日

poj 3761

摘要: #include<iostream>#include<fstream>using namespace std;#define MOD 20100713long long n,m;long long pow (int k, int n){ long long r = k, ans = 1; while (n) { if (n & 1) ans = (ans * r) % MOD; r = (r * r) % MOD; n >>= 1; } return ans;}long long f[1000001];void solve(){ long long 阅读全文

posted @ 2011-07-07 14:14 宇宙吾心 阅读(180) 评论(0) 推荐(0)

poj 1150

摘要: #include<iostream>#include<fstream>using namespace std;int get2(int n){ if(n==0) return 0; return n/2+get2(n/2);}int get5(int n){ if(n==0) return 0; return n/5+get5(n/5);}int odd_get(int n,int x){ if(n==0) return 0; return n/10+(n%10>=x)+odd_get(n/5,x);}int getx(int n,int x){ if(n==0) 阅读全文

posted @ 2011-07-07 12:57 宇宙吾心 阅读(340) 评论(0) 推荐(0)

poj 2918

摘要: #include<iostream>#include<fstream>using namespace std;char map[10][10];int empty[82][2];int a[10][10];int b[10][10];int c[10][10];int ok(int s,int t){ return (s-1)/3*3+(t-1)/3+1;}int len;int dfs(int s){ int x,y,i; x=empty[s][0]; y=empty[s][1]; if(s==len+1) { return 1; } for(i=1;i<=9; 阅读全文

posted @ 2011-07-07 11:42 宇宙吾心 阅读(185) 评论(0) 推荐(0)

poj 2248

摘要: #include<iostream>#include<fstream>using namespace std;int n;int ans;int num[20];int a[20];void dfs(int s){ int i,j,k; if(s>11||s>ans) return; if(num[s]==n){ ans=s; for(i=0;i<=ans;i++) a[i]=num[i]; return; } for(i=s;i>=0;i--) { num[s+1]=num[s]+num[i]; if(num[s+1]>n) contin 阅读全文

posted @ 2011-07-07 11:42 宇宙吾心 阅读(225) 评论(0) 推荐(0)

poj 2935

摘要: #include<iostream>#include<fstream>#include<queue>using namespace std;int map[40][40];int ok(int s,int t){ return (s-1)*6+t;}struct e{ int s,t;};int pre[7][7];int pre1[7][7];int pre2[7][7];int sx,sy,ex,ey;int move[4][2]={0,1,0,-1,1,0,-1,0};int v[7][7];void pr(int s){ if(s==0) cout& 阅读全文

posted @ 2011-07-07 11:41 宇宙吾心 阅读(274) 评论(0) 推荐(0)

poj 2245

摘要: #include<iostream>#include<fstream>using namespace std;int n;int a[14];int v[14];void dfs(int s,int t){ int i; if(n-s+t+1<6) return; if(t==6) { for(i=1;i<=n;i++) if(v[i]) cout<<a[i]<<' '; cout<<endl; return; } v[s]=1; dfs(s+1,t+1); v[s]=0; dfs(s+1,t);}void 阅读全文

posted @ 2011-07-07 11:40 宇宙吾心 阅读(157) 评论(0) 推荐(0)

2011年6月26日

poj 2436

摘要: dfs代码:#include<iostream>#include<fstream>using namespace std;int cow[1001];int n,d,k;int ans;int b[16];void solve(int s,int t,int p){ int i,j; if(d-s+1<k-t) return; if(t==k) { j=0; for(i=1;i<=n;i++) if(cow[i]==(cow[i]&p)) j++; if(j>ans) ans=j; return; } solve(s+1,t+1,p|(1< 阅读全文

posted @ 2011-06-26 21:53 宇宙吾心 阅读(169) 评论(0) 推荐(0)

poj 3411

摘要: 有意思的dfs代码:#include<iostream>#include<fstream>#include<vector>using namespace std;struct node{ int c,p,r,data;};vector<node> edge[11];int n,m;int v[11];int ans;void solve(int s,int w){ int i,j,k; if(w>ans) return; if(s==n) { ans=w; return ; } for(i=0;i<edge[s].size();i++ 阅读全文

posted @ 2011-06-26 21:18 宇宙吾心 阅读(322) 评论(0) 推荐(0)

2011年6月15日

poj 2677

摘要: TSP#include<iostream>#include<fstream>#include<cmath>using namespace std;double dp[101][101];int x[101],y[101];double ok(int s,int t){ return sqrt(1.*(x[s]-x[t])*(x[s]-x[t])+(y[s]-y[t])*(y[s]-y[t]));}int n;void read(){// ifstream cin("in.txt"); int i,j,k; while(cin>> 阅读全文

posted @ 2011-06-15 17:33 宇宙吾心 阅读(262) 评论(0) 推荐(0)

poj 1952

摘要: dp#include<iostream>#include<fstream>using namespace std;int len[5001],time[5001];int a[5001];int n;void read(){// ifstream cin("in.txt"); int i,j,k; cin>>n; for(i=1;i<=n;i++) cin>>a[i]; for(i=1;i<=n;i++) { len[i]=1; time[i]=1; } for(i=1;i<=n;i++) for(j=i-1 阅读全文

posted @ 2011-06-15 16:18 宇宙吾心 阅读(526) 评论(0) 推荐(0)

上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 36 下一页

导航