#include <bits/stdc++.h>
using namespace std;
typedef int ll;
const int maxrs = 305;
const int maxme = 1005;
const ll mod = 1000000007LL;
ll dpkis[maxrs][maxrs][maxme];
ll dpnagy[maxrs][maxrs][maxme];
ll tab[maxrs][maxrs];
int r, s;
ll n, m;
int main()
{
cin>>r>>s>>n;
m = (ll)sqrt(n);
for(int i=0;i<r;i++) {
for(int j=0;j<s;j++) {
cin>>tab[i][j];
}
}
for(int c=1;c<=min(tab[0][0],m);c++) {
dpkis[0][0][c] = 1LL;
}
for(int i=0;i<r;i++) {
for(int j=0;j<s;j++) {
for(int c=1;c<=m;c++) {
int req = (int)max((ll)1,(c + tab[i][j] - 1) / tab[i][j]);
dpkis[i][j][c] += (i > 0 ? dpkis[i-1][j][req] : 0LL);
dpkis[i][j][c] += (j > 0 ? dpkis[i][j-1][req] : 0LL);
dpkis[i][j][c] %= mod;
}
}
}
for(int i=0;i<r;i++) {
for(int j=0;j<s;j++) {
for(int c=1;c<=m;c++) {
if(i == 0 && j == 0 && n <= c) dpnagy[i][j][c] = 1LL;
if(c * tab[i][j] > m) {
int prereq = (n+c-1) / c;
int req = (prereq + tab[i][j] - 1) / tab[i][j];
dpnagy[i][j][c] += (i > 0 ? dpkis[i-1][j][req] : 0LL);
dpnagy[i][j][c] += (j > 0 ? dpkis[i][j-1][req] : 0LL);
dpnagy[i][j][c] %= mod;
}
else {
int req = c * tab[i][j];
dpnagy[i][j][c] += (i > 0 ? dpnagy[i-1][j][req] : 0LL);
dpnagy[i][j][c] += (j > 0 ? dpnagy[i][j-1][req] : 0LL);
dpnagy[i][j][c] %= mod;
}
}
}
}
cout<<dpnagy[r-1][s-1][1]<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
94 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Runtime error |
115 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Runtime error |
179 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Runtime error |
187 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Runtime error |
187 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
6 |
Runtime error |
181 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
7 |
Correct |
96 ms |
39800 KB |
Output is correct |
8 |
Runtime error |
196 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
9 |
Runtime error |
240 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Runtime error |
221 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |