O2都不过,笑死
  • 板块P5173 传球
  • 楼主Donner
  • 当前回复0
  • 已保存回复0
  • 发布时间2022/9/18 15:44
  • 上次更新2023/10/27 10:52:17
查看原帖
O2都不过,笑死
706357
Donner楼主2022/9/18 15:44

卡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]);
}
2022/9/18 15:44
加载中...