我把搜索函数直接写在主函数里测试样例就是对的
```
#include<iostream>
#include<algorithm>
#define maxn 2005
using namespace std;
long long fab[2005][2005];
int t,k,n,m;
long long _f()
{
for(int i=0;i<maxn;i++)
{
fab[i][0]=1;
for(int j=1;j<=i;j++)
{
fab[i][j]=(fab[i-1][j-1]+fab[i-1][j])%k;
}
}
}
int main()
{
cin>>t>>k;
_f();
int cnt;
for(int w=1;w<=t;w++)
{
cnt=0;
cin>>n>>m;
for(int i=0;i<=n;i++)
{
for(int j=0;j<=min(i,m);j++)
{
if(fab[i][j]%k==0) cnt++;
}
}
cout<<cnt<<endl;
}
return 0;
}
```
但是有很多测试点过不去,我知道超时直接搜索会超时,但是为什么会wa啊
by loading777jzr @ 2021-12-14 16:37:06
刚学没多久,求指导T^T
by loading777jzr @ 2021-12-14 16:38:27
您的返回值呢?
by 高启凯 @ 2022-10-05 14:24:45
@[loading777jzr](https://www.luogu.com.cn/user/576093)
by 高启凯 @ 2022-10-05 14:26:18