2011年4月22日

poj 2663

摘要: 关键是递推公式。代码:#include<iostream>#include<fstream>using namespace std;long long a[31];void read(){// ifstream cin("in.txt"); int i,j,k;a[0]=1; a[2]=3;a[4]=11; for(i=6;i<=30;i+=2) a[i]=4*a[i-2]-a[i-4]; while(cin>>i) { if(i==-1) return; if(i%2) cout<<0<<endl; els 阅读全文

posted @ 2011-04-22 16:10 宇宙吾心 阅读(412) 评论(0) 推荐(0)

poj 2229

摘要: 关键是递推公式。代码:#include<iostream>#include<fstream>using namespace std;long long a[1000001];void read(){// ifstream cin("in.txt"); int i,j,k; a[1]=1; a[2]=2; for(i=3;i<=1000000;i++) if(i%2) a[i]=a[i-1]; else { a[i]=a[i-2]+a[i/2]; a[i]%=1000000000; } cin>>i; cout<<a[i] 阅读全文

posted @ 2011-04-22 15:33 宇宙吾心 阅读(235) 评论(0) 推荐(0)

poj 1664

摘要: 递推公式。代码:#include<iostream>#include<fstream>using namespace std;int dp[11][11];int v[11][11];int solve(int s,int t){ if(t==0) return 1; if(s==1) return 1; if(v[s][t]) return dp[s][t]; v[s][t]=1; dp[s][t]=solve(s-1,t); if(t>=s) dp[s][t]+=solve(s,t-s); return dp[s][t];}void read(){// ifs 阅读全文

posted @ 2011-04-22 14:55 宇宙吾心 阅读(159) 评论(0) 推荐(0)

poj 1283

摘要: 关键是递推公式。代码:#include<iostream>#include<fstream>using namespace std;long long dp[201][201];void read(){// ifstream cin("in.txt"); int i,j,k,n,m; for(i=1;i<=200;i++) dp[i][i]=1; for(i=1;i<=200;i++) for(j=i+1;j<=200;j++) dp[i][j]=dp[i-1][j-1]+dp[i][j-i]; while(cin>>n 阅读全文

posted @ 2011-04-22 14:35 宇宙吾心 阅读(232) 评论(0) 推荐(0)

导航