Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
29787 | baka24 | 【BJ】T1 | C++ | 输出超限 | 0 | 1 MS | 312 KB | 1682 | 2024-05-26 21:05:12 |
#include<bits/stdc++.h> using namespace std; #define int long long const int MAXN=1010,B=1000,N=1010,Mod=1000000007; inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f-1;c=getchar();}while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}return x*f;} int s,t,n,m; struct poly{ int x[MAXN],p; poly operator*(const poly&G)const{ poly res; res.p=p+G.p-1; // res.p=min(m-n+2,res.p); for(int i=0;i<res.p;i++)res.x[i]=0; cout<<" "<<p<<" "<<G.p<<endl; cout<<" ";for(int i=0;i<p;i++)cout<<x[i]<<" ";cout<<endl<<"*"; cout<<" ";for(int i=0;i<G.p;i++)cout<<G.x[i]<<" ";cout<<endl; for(int i=0;i<p;i++){ for(int j=0;j<G.p;j++){ res.x[i+j]+=x[i]*G.x[j]%Mod; res.x[i+j]%=Mod; if(i+j>100)break; } } // res.p=min(m-n+2,res.p); cout<<"=";for(int i=0;i<res.p;i++)cout<<res.x[i]<<" ";cout<<endl; return res; } }P; poly Pow(poly x,int y){ poly rt; rt.p=1; rt.x[0]=1; while(y){ if(y&1)rt=rt*x; x=x*x; y>>=1; // cout<<"Pow:"<<y<<" "<<rt.p<<endl; } return rt; } void slv(){ s=read(),t=read(),n=read(),m=read(); P.p=2; P.x[1]=1,P.x[0]=1; poly Q=Pow(P,s-t*n); P=Pow(P,t); // for(int i=0;i<Q.p;i++)cout<<Q.x[i]<<" ";cout<<endl; // for(int i=0;i<P.p;i++)cout<<P.x[i]<<" ";cout<<endl; P.p--; for(int i=0;i<P.p;i++){ P.x[i]=P.x[i+1]; } P=Pow(P,n); P=P*Q; printf("%lld",P.x[m-n]); } signed main(){ slv(); return 0; }