Submission #20160

#TimeUsernameProblemLanguageResultExecution timeMemory
20160drhollow괄호 (kriii4_R)C11
0 / 100
2000 ms8056 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...