[BOJ] 2225 합분해

Time Lapse :10min 2sec

2225.c

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