先写了个搜索,发现果断超时,无奈几天又没有其他的方法,只有打表过~
注意0的时候应该是1,还有数组应该尽量大点,因为为k最大为n2
代码:
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int maxn=74;
int ans[maxn][maxn]={{1},
{1,1},
{1,4,4},
{1,9,26,26,8},
{1,16,92,232,260,112,16},
{1,25,240,1124,2728,3368,1960,440,32},
{1,36,520,3896,16428,39680,53744,38368,12944,1600,64},
{1,49,994,10894,70792,282248,692320,1022320,867328,389312,81184,5792,128},
{1,64,1736,26192,242856,1444928,5599888,14082528,22522960,22057472,12448832,3672448,489536,20224,256}};
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)&&(n+m))
printf("%d\n",ans[n][m]);
return 0;
}