# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
479410 | rainboy | Mobitel (COCI19_mobitel) | C11 | 171 ms | 1168 KiB |
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 <stdio.h>
#define N 300
#define M 300
#define A 300
#define MD 1000000007
int vv[N + M], ff[N + M], gg[N + M];
void init() {
int i;
ff[0] = gg[0] = 1;
for (i = 1; i < N + M; i++) {
vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
ff[i] = (long long) ff[i - 1] * i % MD;
gg[i] = (long long) gg[i - 1] * vv[i] % MD;
}
}
int choose(int n, int k) {
return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}
int main() {
static int aa[N][M], dp[M][A];
int n, m, c, i, j, a, b, ans;
init();
scanf("%d%d%d", &n, &m, &c);
if (c > A) {
printf("0\n");
return 0;
}
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
scanf("%d", &aa[i][j]);
if (aa[0][0] < c)
dp[0][aa[0][0]] = 1;
for (i = 0; i < n; i++)
for (j = 0; j < m; j++) {
if (i == 0 && j == 0)
continue;
a = aa[i][j];
for (b = c - 1; b >= 1; b--)
dp[j][b] = b % a != 0 ? 0 : ((i == 0 ? 0 : dp[j][b / a]) + (j == 0 ? 0 : dp[j - 1][b / a])) % MD;
}
ans = 0;
for (b = 1; b < c; b++)
ans = (ans + dp[m - 1][b]) % MD;
ans = (choose(n - 1 + m - 1, n - 1) - ans + MD) % MD;
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |