My code fails at the 30th test file am i missing some trivial test case.
Please provide me a testcase wheremy code fails
Here's the code
#include<iostream>
//#include<conio.h>
using namespace std;
long choose(long n,long k)
{ long **p,i,j;
p=new long*[n+1];
for(i=0;i<n+1;i++)
p[i]=new long[k+1];
for(i=1;i<n+1;i++)
for(j=0;j<k+1;j++)
{ if(j>i){p[i][j]= 0;continue;}
if(i==j){p[i][j]= 1;continue;}
if(i==1||j==0){p[i][j]= 1;continue;}
p[i][j]=(*p[i-1,j] + *p[i-1,j-1])%1000000007;
} //end for
return p[n][k];
}//end choose
main()
{
long n,m,k,mod=1,bigger ,smaller,temp;
long long output=1;
scanf("%ld%ld%ld",&n,&m,&k);temp=k;
if(k==1){output=m*n;}
else{ if(k>n||k>m)cout<<0;
else
{if(n>m)
{bigger =n;
smaller=m;
}
else
{
bigger=m;
smaller=n;
}
while(temp--!=0)
{output*=(smaller%1000000007);smaller--;output=output%1000000007;}
output*=choose(bigger,k)%1000000007;
}
}//end if outermost
cout<<output;
// getch();
}
and one more thing why statement "p[i][j]=p[i][j-1] + p[i-1][j-i];" gives error
"invalid operands of types long int* and long int* to the binary operator+"
while the statement " p[i][j]=(*p[i][j-1]+ *p[i-1][j-i]);" compiles.
Please reply ........
give me any kind of hint .