# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
105862 | hyn0027 | Mobitel (COCI19_mobitel) | C++11 | 2508 ms | 28772 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 <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define int long long
using namespace std;
const int mod = 1e9 + 7, maxn = 302, maxmmax = 1e6 + 10;
int n, m, mmax, s[maxn][maxn], f[2][maxn][3010], bel[maxmmax], c, mp[maxmmax], premp[maxmmax], ans;
signed main(){
// freopen("mobitel.in", "r", stdin);
// freopen("mobitel.out", "w", stdout);
scanf("%lld%lld%lld", &n, &m, &mmax);
bel[0] = mmax + 1;
for(int i = 1; i <= mmax; i++){
bel[i] = bel[i - 1];
while(bel[i] * i >= mmax) bel[i]--;
bel[i]++;
if(bel[i] != bel[i - 1]) c++;
mp[c] = i;
premp[i] = c;
}
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
scanf("%lld", &s[i][j]);
f[0][0][premp[1]] = 1;
for(int ii = 0, i = 0; ii < n; ii++, i ^= 1)
for(int j = 0; j < m; j++)
for(int k = 1, cur; k <= c; k++){
cur = min(mmax, mp[k] * s[ii][j]);
if(cur == mmax && ii == n - 1 && j == m - 1 && f[i][j][k]) ans += f[i][j][k];
f[i][j + 1][premp[cur]] += f[i][j][k], f[i][j + 1][premp[cur]] %= mod;
f[!i][j][premp[cur]] += f[i][j][k], f[!i][j][premp[cur]] %= mod;
f[i][j][k] = 0;
}
ans %= mod;
printf("%lld\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |