洛谷日常:P1044 栈(1)
程序员文章站
2022-07-13 11:51:36
...
/*洛谷P10044*/
#include <bits/stdc++.h>
#define MAX_N 20
#define ll long long
using namespace std;
int n;
ll f[MAX_N][MAX_N];
ll dfs(int i,int j){
if(f[i][j]) return f[i][j];
if(i==0) return 1;//边界
if(j>0) f[i][j]+=dfs(i,j-1);
f[i][j]+=dfs(i-1,j+1);
return f[i][j];
}
int main(){
scanf("%d",&n);
printf("%lld",dfs(n,0));
return 0;
}
上一篇: dp,洛谷p1044,栈