Submission #1029616

#TimeUsernameProblemLanguageResultExecution timeMemory
1029616atomMagneti (COCI21_magneti)C++17
0 / 110
1 ms604 KiB
#include "bits/stdc++.h" // @JASPER'S BOILERPLATE using namespace std; using ll = long long; #ifdef JASPER #include "debug.h" #else #define debug(...) 166 #endif const int MOD = 1e9 + 7; const int N = 2e4 + 5; int bPow(int a, int b) { ll ans = 1; while (b) { if (b & 1) ans = (1LL * ans * a) % MOD; a = (1LL * a * a) % MOD; b >>= 1; } return ans; } int fac[N], inv[N]; void prepare() { fac[0] = 1; for (int i = 1; i < N; ++i) fac[i] = (1LL * fac[i - 1] * i) % MOD; inv[N - 1] = bPow(fac[N - 1], MOD - 2); for (int i = N - 2; i >= 0; --i) inv[i] = (1LL * inv[i + 1] * (i + 1)) % MOD; } int C(int k, int n) { if (k > n) return 0; return ((1LL * fac[n] * inv[n - k]) % MOD * (inv[k])) % MOD; } signed main() { cin.tie(0) -> sync_with_stdio(0); #ifdef JASPER freopen("in1", "r", stdin); #endif prepare(); int n, l; cin >> n >> l; vector <int> a(n + 1); for (int i = 1; i <= n; ++i) cin >> a[i]; sort(a.begin(), a.end()); if (a[1] == a[n]) { // sub1 int p = (n - 1) * a[1] + 1; ll ans = (1LL * fac[n] * C(n, n + l - p)); cout << ans << "\n"; } 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...