1 #include<bits/stdc++.h> 2 using namespace std; 3 4 typedef long long ll; 5 const ll N=1e6+3,H=1e9+7; 6 ll n,a[N],jc[N],ij[N],iv[N]; 7 void Pre() 8 { 9 jc[0]=ij[0]=iv[0]=iv[1]=1; 10 for(int i=2;i<N;i++)iv[i]=H-(H/i)*iv[H%i]%H; 11 for(int i=1;i<N;i++) 12 jc[i]=jc[i-1]*i%H,ij[i]=ij[i-1]*iv[i]%H; 13 } 14 ll C(ll n,ll m) 15 { 16 if(n<0||m<0||n<m)return 0; 17 return jc[n]*ij[m]%H*ij[n-m]%H; 18 } 19 void Solve() 20 { 21 cin>>n;ll s=0;Pre(); 22 for(int i=1;i<=n+1;i++)cin>>a[i]; 23 for(int i=1;i<=n+1;i++)s=(s+C(i+a[i]-1,i))%H; 24 cout<<s<<endl; 25 } 26 int main() 27 { 28 int T;T=1; 29 while(T--)Solve(); 30 return 0; 31 }View Code
标签:CFglobal21,int,ll,iv,ij,jc From: https://www.cnblogs.com/Hanghang007/p/17069447.html