This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
int N,K;
int cnt = 0;
int D_val(int x, int y)
{
if (x==0 && y==0) return 1;
if (x<0 || y<0 || y>x) return 0;
return (K*D_val(x-1,y))+D_val(x,y-1);
}
int Sum_val(int n)
{
int x;
int ret=0;
for(x=0; x<=n; x++)
ret+= D_val(x,n-x);
return ret;
}
void catalan(int x, int y)
{
printf("x %d y %d\n",x, y);
if (y>x) return;
if (x==N && y==N) {cnt++; return;}
if (x>N || y>N) return;
catalan(x+1,y);
catalan(x, y+1);
}
int main()
{
int i,j,tc,T;
int AnswerN;
int x,y;
/*
freopen("input.txt","r",stdin);
scanf("%d",&T);
for (tc=0; tc<T; tc++) {
printf("%d\n",AnswerN);
} */
scanf("%d %d",&N, &K);
//catalan(0,0);
//cnt = D_val(x,y);
cnt = Sum_val(N);
printf("%d\n",cnt);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |