Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

贴代码~

Posted by 574904658 at 2012-07-19 00:44:45 on Problem 1283
#include "stdio.h"
 long long d[201][201];
long long dp(int N,int M)
{
  int i,j;
  for (i=0;i<=M;i++)
  {
	  d[1][i]=1;
	  d[0][i]=1;
  }
  for (i=0;i<=N;i++)
  {
	  d[i][1]=1;
	  d[i][0]=1;
  }
  for (i=2;i<=N;i++)
	  for (j=2;j<=M;j++)
	  {
		  if (i>j)
			  d[i][j]=d[i][j-1]+d[i-j][j];
		  else if (i==j)
                d[i][j]=d[i][i-1]+1;
		  else 
			    d[i][j]=d[i][i];

	  
	  }
	  return d[N][M];


}


int main()
{
	int N,M;


while (scanf ("%d%d",&N,&M)==2&&(N!=0||M!=0))
    {
	
		printf ("%lld\n",dp(N-M,M) );
	
	}	

return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator