Submission #892365

#TimeUsernameProblemLanguageResultExecution timeMemory
892365vjudge1Magneti (COCI21_magneti)C++17
0 / 110
1 ms604 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int MAXN = 1e4 + 5; const int MOD = 1e9 + 7; typedef pair<long long, int> li; int n, a[MAXN], fact[MAXN], finv[MAXN], l; bool ok=1; vector<li> v; int Pow(int a, int b) { if (b == 0) return 1; int ret = Pow(a, b / 2); ret = 1ll * ret * ret % MOD; if (b & 1) ret = 1ll * ret * a % MOD; return ret; } int C(int n, int k) { return (1ll * fact[n] * finv[n - k] % MOD) * finv[k] % MOD; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); fact[0] = 1; for (int i = 1; i <= 1e4; i++) { fact[i] = 1ll * fact[i - 1] * i % MOD; } finv[10000] = Pow(fact[10000], MOD - 2); for (int i = 1e4 - 1; i >= 0; i--) { finv[i] = 1ll * finv[i + 1] * (i + 1) % MOD; } cin>>n>>l; for(int i = 1; i <= n; i++) { cin>>a[i]; if(i>=2) if(a[i]!=a[i-1]) ok=0; v.push_back({a[i], i}); } // if(ok==1) // { long long res=fact[n]; long long m=l-(n-1)*a[1]-1+n; long long tmp=C(m, n); res=(res*tmp)%MOD; cout<<res; return 0; // } // // int res=0; // do // { // int gap=l-n; // for(int i=1; i<n; i++) // { // gap-=max({v[i-1].first-1, v[i].first-1}); // } // res=(res+C(n+gap, n))%MOD; // } // while(next_permutation(v.begin(), v.end())); // cout<<res; 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...