Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:献上我的第一次In Reply To:献上我的第一次 Posted by:z1160y at 2009-06-11 15:11:20 也献上一次;和楼上思想基本一样儿一样儿的。。(dp+记忆化搜索版+简化版) #include<iostream> using namespace std; __int64 dp[255][255]; __int64 joy_dp(int a,int k) { if(dp[a][k]>0) return (dp[a][k]); if(a==k) return (dp[a][a]=1); if(a<k) return 0; if(a>=2*k) return (dp[a][k]=joy_dp(a-2*k,k)+joy_dp(a,k+1)); else return(dp[a][k]=joy_dp(a,k+1)); } int main() { for(int i=0;i<255;i++) dp[0][i]=1; int n; while(scanf("%d",&n)&&n) printf("%d %I64d\n",n,joy_dp(n,1)); return 0;} Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator