Submission #538544

# Submission time Handle Problem Language Result Execution time Memory
538544 2022-03-17T04:34:23 Z Pichon5 Magneti (COCI21_magneti) C++17
0 / 110
40 ms 39404 KB
#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[5000005];
void init(){
   fact[0]=1;
   for(int i=1;i<=5000000;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;
    cout<<nck(n+libre,n)*fact[n]%MOD<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 39 ms 39372 KB Output is correct
2 Incorrect 40 ms 39340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 39404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 39396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 39 ms 39372 KB Output is correct
2 Incorrect 40 ms 39340 KB Output isn't correct
3 Halted 0 ms 0 KB -