Submission #745235

#TimeUsernameProblemLanguageResultExecution timeMemory
745235Ahmed57Magneti (COCI21_magneti)C++17
10 / 110
27 ms1876 KiB
#include <iostream> using namespace std; #define mod 1000000007 long long fact[100001],inverse[100001]; long long power(long long x,long long n) { if (n == 0) { return 1; } long long pow = power(x, n / 2)%mod; if (n & 1) { return ((((x%mod) * (pow%mod))%mod) * pow%mod)%mod; } return ((pow%mod) * (pow%mod))%mod; } long long solve(int a,int b){ return((fact[a]*inverse[b])%mod*inverse[a-b])%mod; } long long stars(long long a,long long b){ return solve(a+b-b,b); } int main() { fact[0] = inverse[0] = fact[1] = inverse[1] = 1; for(int i = 2;i<=1e5;i++){ fact[i]=fact[i-1]*i; fact[i]%=mod; inverse[i] = power(fact[i],mod-2); } long long n,l,x; cin>>n>>l; for(int i = 0;i<n;i++){ cin>>x; } if(l<(n-1)*x){ cout<<0<<endl; return 0; } cout<<(stars(l-(n-1)*(x-1),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...