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:ld2rxt at 2014-09-16 22:06:20 > #include<stdio.h> > int dp[12][12]; > int justdo(int m, int n) > { > if(m<0) > return 0; > > if(n==1 || m==0) > return dp[m][n] = 1; > > if(dp[m][n]) > return dp[m][n]; > else > { > int num = 0, k = 1; > for(;;k++) > { > num+=justdo(m-k*n,n-1); > if(m-k*n<=0) > break; > } > return dp[m][n] = justdo(m,n-1) + num; > } > } > int main() > { > int t,m,n; > scanf("%d",&t); > while(t--) > { > scanf("%d %d",&m,&n); > printf("%d\n",justdo(m,n)); > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator