|
- #include<iostream>
- using namespace std;
- int n;
- long long ans;
- long long f[20][20][20];
- void dfs(int x,int y,int z)
- {
- if(z==n)
- {
- ans++;
- return;
- }
- if(f[x][y][z])
- {
- ans+=f[x][y][z];
- return;
- }
- int p=ans;
- if(x>0)dfs(x-1,y+1,z);
- if(y>0)dfs(x,y-1,z+1);
- f[x][y][z]=ans-p;
- }
- int main()
- {
- cin>>n;
- dfs(n,0,0);
- cout<<ans;
- return 0;
- }
复制代码 |
|