题目:
已知分段函数
\begin{cases}
1&(n=0,m=0)\
m(m-1)&(n=0)\
n(n+1)&(m=0)
\
f(n-1,m)+f(n,m-1)+f(n-1,m-1)
\end{cases}$$
给定 n,m,求 f(n,m)
想知道暴力复杂度多少,一晚上都没搞出来(
#include <bits/stdc++.h>
using namespace std;
inline int f(int x, int y) {
if(!(x|y)) return 1;
if(!x) return y*(y-1);
if(!y) return x*(x+1);
return f(x-1,y)+f(x,y-1)+f(x-1,y-1);
}
int main(void) {
int n,m;
scanf("%d%d",&n,&m);
printf("%d %d\n",f(n,m));
return 0;
}
求助~