Submission #877132

# Submission time Handle Problem Language Result Execution time Memory
877132 2023-11-22T23:08:22 Z Youssif_Elkadi Magneti (COCI21_magneti) C++17
10 / 110
1 ms 604 KB
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e4 + 5, mod = 1e9 + 7;
long long fac[N], inv[N];
long long n, l;
long long fp(long long base, long long power)
{
    long long ret = 1;
    while (power)
    {
        if (power & 1)
            ret = (ret * base) % mod;
        power >>= 1;
        base = (base * base) % mod;
    }
    return ret;
}
long long ncr(long long nn, long long rr)
{
    return ((fac[nn] * inv[rr]) % mod * inv[nn - rr]) % mod;
}
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
    cin >> n >> l;
    vector<long long> arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    fac[0] = fac[1] = 1;
    for (long long i = 2; i <= l; i++)
        fac[i] = (i * fac[i - 1]) % mod;
    inv[l] = fp(fac[l], mod - 2);
    for (long long i = l - 1; i >= 0; i--)
        inv[i] = (inv[i + 1] * (i + 1)) % mod;
    int boxes = l - (1 + arr[0] * (n - 1));
    if (boxes < 0)
    {
        cout << 0 << endl;
        return 0;
    }
    cout << (ncr(n + boxes, boxes) * fac[n]) % mod << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 604 KB Output isn't correct
12 Halted 0 ms 0 KB -