#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 time |
Memory |
Grader output |
1 |
Correct |
25 ms |
1748 KB |
Output is correct |
2 |
Correct |
27 ms |
1788 KB |
Output is correct |
3 |
Correct |
26 ms |
1740 KB |
Output is correct |
4 |
Correct |
27 ms |
1848 KB |
Output is correct |
5 |
Correct |
27 ms |
1848 KB |
Output is correct |
6 |
Correct |
26 ms |
1848 KB |
Output is correct |
7 |
Correct |
25 ms |
1728 KB |
Output is correct |
8 |
Correct |
25 ms |
1844 KB |
Output is correct |
9 |
Correct |
26 ms |
1752 KB |
Output is correct |
10 |
Correct |
26 ms |
1856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
1764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
1876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
1748 KB |
Output is correct |
2 |
Correct |
27 ms |
1788 KB |
Output is correct |
3 |
Correct |
26 ms |
1740 KB |
Output is correct |
4 |
Correct |
27 ms |
1848 KB |
Output is correct |
5 |
Correct |
27 ms |
1848 KB |
Output is correct |
6 |
Correct |
26 ms |
1848 KB |
Output is correct |
7 |
Correct |
25 ms |
1728 KB |
Output is correct |
8 |
Correct |
25 ms |
1844 KB |
Output is correct |
9 |
Correct |
26 ms |
1752 KB |
Output is correct |
10 |
Correct |
26 ms |
1856 KB |
Output is correct |
11 |
Incorrect |
26 ms |
1764 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |