Submission #538546

#TimeUsernameProblemLanguageResultExecution timeMemory
538546Pichon5Magneti (COCI21_magneti)C++17
10 / 110
2 ms696 KiB
#include <bits/stdc++.h> #define vi vector<int> #define pb push_back #define ll long long #define F first #define S second #define mp make_pair #define ii pair<int,int> #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; const ll MOD=1e9+7; int n,l,x; const int tam=10005; ll fact[50005]; void init(){ fact[0]=1; for(int i=1;i<=50000;i++){ fact[i]=(fact[i-1]*i)%MOD; } } ll Pou(int a, int n){ if(n==0)return 1; if(n%2==0){ ll A=Pou(a,n/2); return (A*A)%MOD; }else{ ll A=Pou(a,n/2); A=(A*A)%MOD; return (A*a)%MOD; } } ll nck(int n, int k){ ll res=(fact[n]*Pou((fact[k]*fact[n-k])%MOD,MOD-2))%MOD; return res; } int main(){ init(); cin>>n>>l; for(int i=0;i<n;i++){ cin>>x; } ll libre=l-(n-1)*x-1; if(libre<0){ cout<<0<<endl; return 0; } cout<<nck(n+libre,n)*fact[n]%MOD<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...