卡O2都过不去
真的废了……
https://www.luogu.com.cn/record/86904012
#include <bits/stdc++.h>
#define mul(a,b) ((long long)(a)*(b)%mod)
using namespace std;
const int MAXN=10000;
const int mod=1000000007;
int n,m,a[MAXN],ans[MAXN];
inline int add(int a,int b){
a+=b;
return a>=mod?a-mod:a;
}
void polymul(int *a,int *b,int *c,int n){
int tmp[MAXN];
memset(tmp,0,sizeof(int)*n*2);
for(int i=0; i<n; i++){
if(a[i]){
for(int j=0; j<n; j++){
tmp[i+j]=add(tmp[i+j],mul(a[i],b[j]));
}
}
}
for(int i=0; i<n; i++){
c[i]=tmp[i];
}
for(int i=n; i<2*n; i++){
c[i-n]=add(c[i-n],tmp[i]);
}
}
int main(){
scanf("%d%d",&n,&m);
++a[1];++a[n-1];
ans[0]=1;
while(m){
if(m&1){
polymul(ans,a,ans,n);
}
polymul(a,a,a,n);
m>>=1;
}
printf("%d",ans[0]);
}