Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
29772 | LYLAKIOI | 【BJ】T1 | C++ | 通过 | 100 | 186 MS | 296 KB | 1189 | 2024-05-26 19:51:30 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);++i) #define p_b push_back #define pi pair<int,int> #define m_p make_pair #define p1 first #define p2 second using namespace std; typedef long long ll; const int maxn=1e6+10,mod=1e9+7; inline ll read(){ ll x=0;short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; } ll n,m,s,t; #define Poly vector<int> Poly operator*(Poly a,Poly b){ Poly c;c.resize(min(int(a.size())+int(b.size())-1,(int)(m-n)+5)); up(i,0,int(a.size())-1)up(j,0,int(b.size())-1){ if(i+j>m-n+2)break; (c[i+j]+=a[i]*1ll*b[j]%mod)%=mod; }return c; } Poly qpow(Poly a,ll b){ Poly res;res.resize(1),res[0]=1; while(b){ if(b&1)res=res*a; a=a*a;b>>=1; }return res; } void slv(){ s=read(),t=read(),n=read(),m=read(); Poly w;w.resize(2),w[0]=w[1]=1; Poly g=qpow(w,s-t*1ll*n); Poly h=qpow(w,t); h.erase(h.begin());h=qpow(h,n); g=g*h; cout<<g[m-n]; }int main(){ slv(); return 0; }