Submission #20160

# Submission time Handle Problem Language Result Execution time Memory
20160 2016-02-29T16:14:05 Z drhollow 괄호 (kriii4_R) C
0 / 100
2000 ms 8056 KB
#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
1 Execution timed out 2000 ms 8056 KB Program timed out
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -