Submission #1237516

#TimeUsernameProblemLanguageResultExecution timeMemory
1237516zadniprovskaMagneti (COCI21_magneti)C++20
0 / 110
1 ms324 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const ll mod = 1e9 + 7; const ll DIM = 1e5 + 7; ll a[DIM], fact[DIM], rfact[DIM]; ll C(ll n, ll k) { return (((fact[n] * rfact[k]) % mod) * rfact[n-k]) % mod; } ll binpow (ll a, ll p) { ll ans = 1; while (p) { if (p & 1) { ans *= a; ans %= mod; } a *= a; a %= mod; p >>= 1; } return ans; } int main(){ ios::sync_with_stdio(false);cin.tie(nullptr); cout.tie(nullptr); ll n, L; cin >> n >> L; ll r; for (int i=1; i<=n; i++) { cin >> r; } if (n == 1) { cout << L << endl; return 0; } fact[0] = 1; for (int i=1; i<=n; i++) { fact[i] = fact[i-1] * i; } rfact[0] = 1; for (int i=1; i<=n; i++) { rfact[i] = binpow(fact[i], mod-2); } ll answer = 0; for (int i=n+(n-1)*(r-1); i<=L; i++) { answer += C(i - n - (n-1)*(r-1) + n-1 - 1, n-2); answer %= mod; } cout << (answer * fact[n]) % mod << endl; } ;
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...