fork download
  1. #include<bits/stdc++.h>
  2. #define int long long
  3. using namespace std;
  4. const int N=105;
  5. const int mod=1e9+7;
  6. int n,f[12][N],a[N],C[N][N];
  7. main()
  8. {
  9. ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  10. cin>>n;
  11. for(int i=0;i<=n;i++)C[i][i]=C[i][0]=1;
  12. for(int i=2;i<=n;i++){
  13. for(int j=1;j<i;j++)C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
  14. }
  15. for(int i=0;i<=9;i++)cin>>a[i];
  16. int ans=0;
  17. for(int m=1;m<=n;m++){
  18. for(int x=1;x<=9;x++){
  19. a[x]--;
  20. memset(f,0,sizeof f);
  21. f[10][0]=1;
  22. for(int i=9;i>=0;i--){
  23. for(int j=0;j<=m-1;j++){
  24. for(int k=max(a[i],0ll);k<=m-1-j;k++){
  25. f[i][j+k]=(f[i][j+k]+f[i+1][j]*C[m-1-j][k]%mod)%mod;
  26. }
  27. }
  28. }
  29. (ans+=f[0][m-1])%=mod;
  30. a[x]++;
  31. }
  32. }
  33. cout<<ans;
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty