This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <map>
const int p = 1092616193;
using namespace std;
int f(int x, int y)
{
return y & 1 ? (long long)f(x, y ^ 1)*x%p : y ? f((long long)x*x%p, y >> 1) : 1;
}
int a[1001];
int d[5005];
int main()
{
int i, j, n, m, t, s = 0;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++)
{
scanf("%d", a + i);
s += a[i];
}
s = f(s, p - 2);
for (i = n; i <= m; i++)
{
t = 0;
for (j = 0; j < n; j++) t = (t + (long long)a[j] * d[i + j - n]) % p;
d[i] = ((long long)t * s + 1) % p;
}
printf("%d", d[m]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |