Submission #102529

# Submission time Handle Problem Language Result Execution time Memory
102529 2019-03-25T17:31:04 Z Nnandi Mobitel (COCI19_mobitel) C++14
130 / 130
1487 ms 5624 KB
#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][maxme];
ll dpkisuj[maxrs][maxme];
ll dpnagy[maxrs][maxme];
ll dpnagyuj[maxrs][maxme];
ll tab[maxrs][maxrs];
int r, s;
ll n, m;

int main()
{
    cin>>r>>s>>n;
    m = 1000;

    for(int i=0;i<r;i++) {
        for(int j=0;j<s;j++) {
            cin>>tab[i][j];
        }
    }

    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]);
                dpkisuj[j][c] = 0LL;
                if(i==0 && j==0 && c<=tab[i][j]) dpkisuj[j][c] = 1LL;
                dpkisuj[j][c] += (i > 0 ? dpkis[j][req] : 0LL);
                dpkisuj[j][c] += (j > 0 ? dpkisuj[j-1][req] : 0LL);
                dpkisuj[j][c] %= mod;
            }
            for(int c=1;c<=m;c++) {

                if(c * tab[i][j] > m) {
                    int prereq = (n+c-1) / c;
                    int req = (prereq + tab[i][j] - 1) / tab[i][j];
                    dpnagyuj[j][c] = 0LL;
                    if(i == 0 && j == 0 && n <= c) dpnagyuj[j][c] = 1LL;
                    dpnagyuj[j][c] += (i > 0 ? dpkis[j][req] : 0LL);
                    dpnagyuj[j][c] += (j > 0 ? dpkisuj[j-1][req] : 0LL);
                    dpnagyuj[j][c] %= mod;
                }
                else {
                    int req = c * tab[i][j];
                    dpnagyuj[j][c] = 0LL;
                    if(i == 0 && j == 0 && n <= c) dpnagyuj[j][c] = 1LL;
                    dpnagyuj[j][c] += (i > 0 ? dpnagy[j][req] : 0LL);
                    dpnagyuj[j][c] += (j > 0 ? dpnagyuj[j-1][req] : 0LL);
                    dpnagyuj[j][c] %= mod;
                }
            }
        }
        swap(dpkis,dpkisuj);
        swap(dpnagy,dpnagyuj);
    }
    cout<<dpnagy[s-1][1]<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1487 ms 5504 KB Output is correct
2 Correct 1476 ms 5624 KB Output is correct
3 Correct 204 ms 5368 KB Output is correct
4 Correct 206 ms 5368 KB Output is correct
5 Correct 206 ms 5340 KB Output is correct
6 Correct 199 ms 5248 KB Output is correct
7 Correct 109 ms 5248 KB Output is correct
8 Correct 755 ms 5500 KB Output is correct
9 Correct 1394 ms 5624 KB Output is correct
10 Correct 1418 ms 5544 KB Output is correct