简单DP
#include"stdio.h" #include"string.h" int main() { int dp[222]; int i,j,n; while(scanf("%d",&n)!=EOF) { memset(dp,0,sizeof(dp)); dp[0]=1; for(i=1;i<=n;i++) for(j=i;j<=n;j++) dp[j]+=dp[j-i]; printf("%d\n",dp[n]); } return 0; }
简单DP
#include"stdio.h" #include"string.h" int main() { int dp[222]; int i,j,n; while(scanf("%d",&n)!=EOF) { memset(dp,0,sizeof(dp)); dp[0]=1; for(i=1;i<=n;i++) for(j=i;j<=n;j++) dp[j]+=dp[j-i]; printf("%d\n",dp[n]); } return 0; }