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

用组合数学数公式Pk(n+k)怎么会错呢!!不懂??

Posted by ecjtubaowp at 2007-01-25 14:55:26 on Problem 3181
#include<stdio.h>
double a[1001][1001];
int main()
{
  int i,j,n,m,k,b;
  double sum;
  for(i=1;i<=1000;i++)
 {
  for(j=1;j<=100;j++)
  {
   if((i==j)||(j==1)){a[i][j]=1;continue;}
   if(i>j)
   {
    for(b=1;b<=j;b++)
    a[i][j]+=a[i-j][b];
   }
   if(i<j)a[i][j]=0;
   
  }
 }
 scanf("%d%d",&n,&k);
 sum=0;
 for(i=1;i<=k;i++)
 sum+=a[n][i];
 printf("%.0lf\n",sum);
 //while(1);
}

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