[BOJ] 4811 알약

Time Lapse :8min 0sec

4811.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <memory.h>
long long dp[31][31];
long long f(int w, int h){
if(dp[w][h]!=-1) return dp[w][h];
dp[w][h] = 0;
if(w) dp[w][h] += f(w-1,h+1);
if(h) dp[w][h] += f(w,h-1);
return dp[w][h];
}
int main() {
int tc;
scanf("%d",&tc);
memset(dp,-1,sizeof(dp));
dp[0][0] = 1;
while(tc){
printf("%lld\n",f(tc,0));
scanf("%d",&tc);
}
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/BOJ/4811/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.